alias g="git show"
alias gh="git show HEAD"
alias gs="git status"
alias gl="git log"
alias gco="git checkout"
alias gd="git diff"
alias gbl="git branch -v"
alias gbd="git branch -D"
alias gri="git rebase --interactive"
alias grc="git rebase --continue"
alias gra="git rebase --abort"
alias gst="git stash"
alias gsta="git stash apply"
alias gx="gco -- \*; git reset HEAD \*"
alias gcp="git cherry-pick"
alias gcpc="git cherry-pick --continue"
alias gcpa="git cherry-pick --abort"
A few hundred instances of "gs" in my .zhistory :)Aliases in my ~/.gitconfig:
[alias]
co = checkout
cm = !git add -A && git commit
br = branch
ci = commit
st = status
unstage = reset HEAD --
recent = for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(refname:short)"
overview = log --all --oneline --no-merges
recap = !git log --all --oneline --no-merges --author=${1-$(git config user.email)}
today = !git log --all --since=00:00:00 --oneline --no-merges --author=${1-$(git config user.email)}
changelog = !git log --oneline --no-merges ${1-$(git describe --abbrev=0)}..HEAD
upstream = !git log --oneline --no-merges HEAD..${1-$(git branch -lvv | perl -ne '/^\\*.*\\[(.*?)\\]/ and print "$1\n"')}
local = !git log --oneline --no-merges ${1-$(git branch -lvv | perl -ne '/^\\*.*\\[(.*?)\\]/ and print "$1\n"')}..HEAD
graph = log --oneline --graph --all --decorate --date=iso
save = !git add -A && git commit -m 'SAVEPOINT'
undo = reset HEAD~1 --mixed
backup = !git push origin/backup/$(whoami)/$(git branch)
lint = !git branch --merged | grep -v \"^\\s*master$\" | grep -v \"\\*\" | xargs -n 1 git branch -d alias st='git status'
alias dp='git diff'
alias di='git diff --cached'
alias aa='git add -A'
alias cm='git commit -m'
alias pu='git push'
Having these aliases of mine makes these actions something that you don’t need to spend any mental effort to perform at all.I highly recommend others to define aliases that make sense to them for the most used got commands.
Mine are named the way they are because the two letter alias represents how I think of the action that the command performs:
* st - status
* dp - diff pending
* di - diff
* aa - add all
* cm - commit
If you define your aliases this way (speaking to the other readers of this thread, not the person I am replying to), you will find that the combinations become muscle memory quickly.
Notice also that unlike a lot of other people including the person I am replying to, my aliases are not prefixed with “g”. Again this boils down to your personal way of thinking. I’ve used other version control systems before, switched to git several years ago, and use git pretty much exclusively. I am of course aware at all times that I am working with git, but at the same time when I think of actions to perform, I don’t think of them as “git this or that”, I only think of the “this or that” part. If that makes sense :P
But yeah, find aliases that work and make sense for you.
No need to install oh-my-zsh you can just take the file or cherry pick (!) the useful ones.
I may drop oh-my-zsh completely and just set up zsh with the small subset of plugins I use.
[1] https://github.com/robbyrussell/oh-my-zsh/tree/master/plugin...
alias ..="cd .."
alias ..2="cd ../.."
# ... you get the idea, mine goes up to 5
function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; }
alias h="history|grep" function up() { cd "$(printf '../'%.0s $(seq 1 "${1:-1}"))" && pwd; } #up 4 goes up 4 directories alias ...="cd ../.."
alias ....="cd ../../.." alias glol="git log --oneline"
...comes in handy as well, and it's fun to type. alias lg = log --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%cd %<(20,trunc)%an %C(auto)%h%Creset%C(auto)%d%Creset %s'Since git is by far the command a lot of people type the most, this shell comes in really handy. It supports all regular git aliases, has autocompletion, and you can set default commands to be run when you just press return. It's amazing how much typing it saves.
Here are my top commands by frequency of use:
total is of ~16k history lines... this means one in ever 4 commands I type is git! Wow I didn't know that. Probably `git status`...