Git & Github

Git & Github

DAY 1

·

2 min read

Diving into Git & GitHub! 🌟

Today marks the beginning of my journey into the world of version control with Git and GitHub! For those new to these tools:

Git: A powerful version control system that helps you manage and track changes in your source code.
GitHub: A cloud-based platform where you can host your Git repositories, collaborate with others, and showcase your projects to the world.

GIT COMMANDS:
git init: Initialize a new Git repository.
git status: Check the status of files and their changes.
git log: View the commit history.
git add: Stage files for the next commit.
git commit -m: Commit changes with a message.
git restore --staged: Move files back to the unstaged area.
git reset <Hash ID>: Remove commits by hash ID.
git stash: Temporarily save changes that are not ready to be committed.
git stash pop: Reapply stashed changes.
git stash clear: Permanently remove stashed changes.
git remote add origin <URL>: Connect your local repository to GitHub.
git push origin master: Push changes to GitHub.

IMPORTANT NOTE:
1. Never commit directly to the main branch—especially in open source projects.
2. Create a new branch for changes to avoid affecting the main branch.

git branch <branch-name>: Create a new branch.
git checkout <branch-name>: Switch to a branch and point the head to the current branch
git merge: Merge changes from one branch into another.
git clone <URL>: Clone a repository to your local system.

Additional Commands:
git fetch --all --prune: Fetch all updates from the remote repository.
git reset --hard upstream main: Reset your branch to match the upstream main branch.
git rebase -i: Explore more to understand the concept
Merge Conflict occurs when multiple people edit the same part of a code on the same line.