Xavier suggested I blog my Git aliases.
[alias] ci = commit -v prune-all = !git remote | xargs -n 1 git remote prune record = !git add -p && git ci amend-record = !git add -p && git ci --amend stoat = !toilet -f future STOATS update-master = !git checkout master && git pull -r lol = log --graph --decorate --pretty=oneline --abbrev-commit lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
Mostly ((No, I don’t remember why I added git stoat either.)) self-explanatory.
- git ci
- Shorter than git commit, and -v shows you what you’re about to commit.
- git prune-all
- From the Git wiki.
- git record; git amend-record
- I started using these as a Darcs refugee, but they’re also a good way to avoid doing git add -p && git commit -a through overly-active muscle memory. I could probably simplify them to use git commit -p.
- git lol; git lola
- …come from Conrad Parker.
What’re your favourites?
I’ve been using lol and lola for a while now, and I just couldn’t do without them.
I’m also always running in the “git add -p; git commit -a” trap, so I’ll take a serious look at that record alias. 🙂
Thanks!
a bunch of things I’ve stolen around GitHub and the kernel mailing list:
fixup is mostly because I like to commit immediately and then do stuff like whitespace cleaning of the newly committed code, or fixing typos in the docs, or adding tests, before pushing.
s = status -sb
At work, we use git a lot like most people use svn as a central code repository. As a result, there is a policy in place to prevent merge commits and enforced with hooks. In svn-land, “svn up” is vaguely equivalent to “git pull –rebase” so I’ve got an alias named “git up” which does just that. I also added an alias named “down” that is just “push”. The workflow is when a merge commit gets rejected, I’ve simply got to to:
git up && git down
It makes me laugh every single time.
A few others:
wdiff = diff –color-words
wshow = show –color-words
egrep = grep -E
createpatch = format-patch -M -C –patience –full-index
diffstat = diff –stat
staged = diff –cached
unstaged = diff
cp = cherry-pick
ci = commit
co = checkout
st = status
stu = status –untracked=no
br = branch
up = pull –rebase
@Jeff Schroeder: oh, nice, I didn’t know about –patience. It’d be nice if one could make Git always use that—the example Bram Cohen gives makes me irrationally angry!
@Emmanuele: I use
very extensively 🙂
So, you can make autosquash default to yes, which is nice, so my ‘rbi’ alias means I just type ‘git rbi’ compulsively to automatically clean up history.
These are my shell functions:
And my aliases:
and ~/bin/r-b:
[Edited to add pre tags.]
@Emmanuele: What’s the difference between `git log -p –no-walk` and `git show`?