Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git blackbelt commands
# Change the config editor to notepad
git config --global core.editor notepad
# ...and then edit the config
git config --global --edit
# Revert master back by 5 commits
git revert --no-commit HEAD~5..
# Revert master back by 5, but do it so there you get a "Revert commit" for each commit you reverted (this opens Vim)
git revert master~5..master
# Display the last 3 commits as single lines, abbreviate the SHA
git log -n 3 --pretty=oneline --abbrev-commit
# Find a commit e.g. delete
new-alias grep select-string
git log --format=oneline --abbrev-commit | grep myfile.js
# Ignore a file (that's been added prior to a .gitignore)
git update-index --assume-unchanged path/to/file
# Un-ignore that file
git update-index --no-assume-unchanged path/to/file
# Reset all staged checkins
git reset --hard
# Clean all unstaged checkins
git clean -n
# Clean all
git clean -xcd
# Turn all uncommitted changes into a new branch
git checkout -b <branchname>
# Find list of changes for a directory
git log --name-status -10 path/to/dir
# Remember usernames/passwords in Git extensions.
# Add this to your .gitconfig file
[credential]
helper = !\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\"
# List all remote branches
git remote show origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.