Skip to content

Instantly share code, notes, and snippets.

@svperfecta
Last active October 10, 2015 12:37
Show Gist options
  • Save svperfecta/3691265 to your computer and use it in GitHub Desktop.
Save svperfecta/3691265 to your computer and use it in GitHub Desktop.
Useful Git Stuff
# 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