git config --list
Set global name used for commiting $ git config --global user.name "[name]"
Set global email used for commiting $ git config --global user.email "[email address]"
Create new local repository git init [project-name]
Copy repository from remote $ git clone [url]
Lists all files to be commited $ git status
Snapshots the file for commit $ git add [file]
Unstages the file, but preserve its contents $ git reset [file]
Shows file differences not yet staged $ git diff
Shows file differences between staging and the last file version $ git diff --staged
Commit all staged changes $ git commit -m "[message]"
Lists all local branches in the current repository $ git branch
$ git branch [branch-name]
Switches to the specified branch and updates the working directory $ git checkout [branch-name]
Merge branch with current branch $ git merge [branch]
$ git branch -d [branch-name]
Deletes the file from the working directory and stages the deletion $ git rm [file]
Removes the file from version control but preserves the file locally $ git rm --cached [file]
Renames prepares it for commit $ git mv [file-original] [file-renamed]
Lists version history for the current branch $ git log
$ git log --graph
Lists version history for a file, including renames $ git log --follow [file]
Display author of all changes in file $ git blame [file]
Shows content differences between two branches $ git diff [first-branch]...[second-branch]
Display changes in the specified commit $ git show [commit]
Undoes all commits afer [commit], preserving changes locally $ git reset [commit]
Discards all history and changes back to the specified commit $ git reset --hard [commit]
Temporarily stores all modified tracked files $ git stash
Lists all stashed changesets $ git stash list
Restores the most recently stashed files $ git stash pop
Discards the most recently stashed changeset $ git stash drop
Downloads all history from the repository bookmark $ git fetch [bookmark]
Combines bookmark’s branch into current local branch $ git merge [bookmark]/[branch]
Uploads all local branch commits remote $ git push [alias] [branch]
Downloads bookmark history and incorporates changes $ git pull