Git Cheat Sheet
Git helps to keep track of code at specific intervals.

Initialize a git repo
git initAdd files to the staging area
git add fileName OR git add .The
git add .command is used to add all the files to the staging area.Commit staged changes
git commit -m "message for the commit"View commit history
git logCreate a new branch
git branch branch-name git checkout -b new-branch git switch -c branch-nameThe
checkoutandswitchcommand creates a new branch and switches to the created branch but thebranchcommand does-not switch the branch automatically.Merge two branches
git mergeFor git merge to work properly you should be located in the branch where the additional information from the other branch should be added to. Suppose we need to merge branch-3 to the main branch then we should be in the main branch.
Delete Branches
git branch -d/-D branch-nameThe
git branch -d/-D branch-nameis used to delete a specific branch. The small -d will only allow you to delete branches if you merge these branches. The capital -D will force the deletion, this means the branch will be deleted, no matter if you merged it or not.
A great resource for understanding git.



