Last active
October 10, 2015 12:37
-
-
Save svperfecta/3691265 to your computer and use it in GitHub Desktop.
Useful Git Stuff
This file contains hidden or 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
# Display short hash | |
git rev-parse --short HEAD | |
# Delete all merged local branches | |
git branch --merged | grep -v '^* master$' | grep -v '^ master$' | xargs git branch -d | |
# Pretty git log (shows branches) | |
alias gg='git log --oneline --abbrev-commit --all --graph --decorate --color' | |
# Diff a file against the last change | |
git diff HEAD@{1} filename | |
# Diff a directory against the last change | |
git diff HEAD@{1} | |
# Remove node_modules from history | |
git filter-branch --tree-filter 'rm -rf node_modules' HEAD | |
echo node_modules/ >> .gitignore | |
git add .gitignore | |
git commit -m 'Removing node_modules from git history' | |
git gc | |
git push origin master --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment