Skip to content

Instantly share code, notes, and snippets.

@willtim
Created November 17, 2017 16:43
Show Gist options
  • Save willtim/3ab24eadf820a81fb4e7a67f76553ff4 to your computer and use it in GitHub Desktop.
Save willtim/3ab24eadf820a81fb4e7a67f76553ff4 to your computer and use it in GitHub Desktop.
Git cheatsheet
* Git Cheatsheet
git stash --keep-index
git clean -d -n
git commit --amend (amend last commit)
git reflog (a history of the commits HEAD has been pointed at; undo pulls, rebases etc)
git add -u (update index, removes and modifies index entries but adds no new files)
git add -i (interactive)
git add -p (patch - interactively choose hunks of patch)
git reset --soft (pointer)
--mixed (pointer,index)
--hard (pointer,index,working)
git log -Ssome_string (where no. occurences of string has changed)
git log --decorate
git log --all (all sibling branches)
git log --oneline
git log --graph
git diff br1:file1 br2:file2
git remote show origin (show remote branches)
git push -u origin branch_name (push local branch and set up tracking)
git push origin --delete branch (delete remote branches)
git rev-list --all | xargs git grep <regexp> (search for commit content)
git config --global alias.tree "log --graph --decorate --pretty=oneline --abbrev-commit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment