Last active
April 2, 2018 17:12
-
-
Save yetanotherchris/2f4d5527a2a373e12181 to your computer and use it in GitHub Desktop.
Git blackbelt commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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