Show Menu
Cheatography

git Cheat Sheet (DRAFT) by

Standard git Concepts

This is a draft cheat sheet. It is a work in progress and is not finished yet.

git checkout

git checkout <branch>

Restore working tree files

git restore <FILE_PATH>

Git Merge Conflicts

<<<<<<< HEAD
your current branch's version of the code
=======
incoming branch's version of the code
>>>>>>> incoming-branch-name
When Git cannot automa­tically merge two versions of a file it inserts conflict markers directly into the file.
Everything between <<<­<<<< HEAD and ======= is your current branch's version.

Everything between ======= and >>>­>>>> branch­-name is the incoming branch's version.

To resolve, delete the markers and keep whichever version (or combin­ation) is correct.
 

git config

git config --global user.name "Your Name"     # set global username
git config --global user.email "you@email.com" # set global email

git config --local user.name "Work Name"      # override for this repo only

git config --list                             # show all current settings
git config user.name                          # show a specific setting
Sets config­uration options for Git at different scopes.
--global applies to all reposi­tories for the current user, --local applies only to the current reposi­tory.
Stored in ~/.git­config for global and .git/c­onfig for local.
 

gut reflog

git reflog

git fetch

git fetch <branch-name>
git fetch downloads commits, branches, and tags from a remote repository into your local repo — but does not modify your working directory or current branch.