Reset commited changes to one or more files. (HEAD~1) refers to the commit prior to HEAD
git checkout HEAD~1 -- file1/to/restore file2/to/restore
Pull a branch without checking it out
git fetch origin name_of_branch:name_of_branch
Move branch pointer to different commit
git branch -f branch-name new-tip-commit
List all branches and their current commits
git push origin :name_of_branch
Track remote branch, create and switch to local copy
git checkout --track origin/name_of_branch
Create remote branch ready for pull
git push -u origin name_of_branch
git config --global --edit
Create branch from a given commit
git branch name_of_branch 6436d7ac
See all branches merged into current branch
See all branches not merged into current branch
List all branches containing a given commit
git branch --contains 6436d7ac
Create a copy of a given commit in current branch
Remove untracked files (use -n for preview, -d for directories)
git config --get core.excludesfile
git config --global core.excludesfile path_to_gitignore
Ignore an already tracked file
git update-index --assume-unchanged name_of_file (--no-assume-unchanged to reset)
git checkout 6436d7ac . (for current branch) git checkout 6436d7ac -b name_of_branch (for another branch)
Determine which branches contain a given commit
git branch -a --contains 6436d7ac
Search for remote branches by name
git branch -r | grep ' DRAGE'
During merge, choose either theirs or ours
git checkout --theirs file_name
git add file_name
Remove stale branches from remote
Find best common ancestor between two branches (usually branching point)
git merge-base name_of_branch1 name_of_branch2
Prevent loss of merges when rebasing
git rebase --preserve-merges origin/name_of_branch name_of_branch
Determine which commmits exists localy but not remotely
git log origin/name_of_branch..name_of_branch
Rewrite most recent commit message
Print commit log by author
git log --author=" name regex" (--name-only for affected files only)