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.