Skip to content

Instantly share code, notes, and snippets.

@SgtPooki
Last active August 29, 2015 14:04
Show Gist options
  • Save SgtPooki/0e5a5c3478e03d1a18bc to your computer and use it in GitHub Desktop.
Save SgtPooki/0e5a5c3478e03d1a18bc to your computer and use it in GitHub Desktop.
git config
[user]
name = Russell Dempsey
email = [email protected]
[core]
autocrlf = false
editor = vim
[push]
default = current
[credential]
### Linux ###
# helper = cache --timeout=84600
### Windows ###
helper = wincred
[alias]
### Reverse the last commit ###
undo-commit = reset --soft 'HEAD^'
### remove a file from the index, but keep the changes ###
unstage = !sh -c 'git reset HEAD $1'
### get the current branch name ###
branchn = rev-parse --abbrev-ref HEAD
### clears everything except untracked changes. Make git status show as clean. ###
trash-tracked = !sh -c \"git stash && git stash drop\"
### trashes everything! Make git status show as clean and remove untracked files. ###
trash-all = !sh -c \"git add . && git stash && git stash drop\"
### Search commits in the history of the repo for a string of text. Use in place of git blame for quicker results. ###
find = !sh -c \"git log -S '$1'\"
### Force your code to clone some upstream's branch ###
mirror = !sh -c \"git fetch '$1' && git reset --hard '$1'/'$2'\"
### Push the current branch you are on to some upstream's branch. ###
pushto = !sh -c \"git push '$1' '$(git branchn)':'$2'\"
### list all of your git aliases ###
alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\t=> \\2/' | sort #thanks http://blog.blindgaenger.net/advanced_git_aliases.html
### random commit message thanks to whatthecommit.com
commit-rnd = !sh -c \"git commit -m '$(curl -s http://whatthecommit.com/index.txt)'\"
### view all files edited by a specific user
author-files = !sh -c \"git log --pretty='%H' --author='$1' | while read commit_hash; do git show --oneline --name-only $commit_hash | tail -n+2; done | sort | uniq\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment