Git Cheat Sheet

It is a good idea to work on a branch other than master. You can create your own branch like this:

git checkout -b $BRANCH_NAME

The “-b” will create a new branch. If you want to switch back and forth between branches, use the checkout command without the “-b” option:

git checkout $BRANCH_NAME

To get a list of all your branches:

git branch

When you want to push, you pull the latest code from the master branch, check out your branch, merge your branch with master, fix any conflicts, check out master, and merge it with your branch.

git add .

git commit -m "Some message"

git checkout master

git pull origin master

git checkout $BRANCH_NAME

git merge master

git checkout master

git merge $BRANCH_NAME

git push origin master


If you move or delete a file, you will need to make that information known to git. You do this by entering

git rm /path/to/file

for deleting a file, and

git mv /path/to/file

to move a file.