What git aliases do you use? Why do you like them?
For further actions, you may consider blocking this person and/or reporting abuse
What git aliases do you use? Why do you like them?
For further actions, you may consider blocking this person and/or reporting abuse
Latest comments (16)
Here are mine:
alias gpc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"'if you don't have anything, this would suffice alone. i always forget how to push my new branch to remote...
Here is my list of
gitaliasShorthand for using git (bash/zsh alias):
alias g=gitUndo the last commit:
undo = reset --soft HEAD^Get a summary of commits since yesterday (useful during standups):
standup = !"git log --reverse --branches --since=$(if [[ "Mon" == "$(date +%a)" ]]; then echo "friday"; else echo "yesterday"; fi) --author=$(git config --get user.email) --format=format:'%C(cyan) %ad %C(yellow)%h %Creset %s %Cgreen%d' --date=local"Push to origin:
pp = push originForce push to origin:
ppf = push origin --force-with-leasePretty log:
lol = log --pretty=format:"%C(yellow)%h\\ %Cblue%G?%Cred%d\\ %Creset%s%Cgreen\\ (%cr)%Cblue\\ [%cn]" --decorate --graphone for lazy remote tracking of the current branch
My standard response:
The case against aliases
Ben Sinclair ・ Sep 3 '18 ・ 1 min read
This is a must have on my
.bashrc:These are from the oh-my-zsh git plugin:
github.com/robbyrussell/oh-my-zsh/...
alias.hug merge --ff-onlyud = "!f() { git checkout develop && git pull origin develop; }; f"
lbranch = "!f() { git rev-parse --abbrev-ref @{-1}; }; f"
udrcb = "!f() { git ud && git checkout $(git lbranch) && git rebase develop; }; f"
An alias to show my aliases:
alias.alias config --get-regexp ^alias\.An alias to make a branch, with a date suffix:
alias.mkbr !f(){ local args="$*"_; local gituser=$(git config user.email); gituser=${gituser%@*}; if [ "$args" = "_" ]; then args=""; fi; args=${gituser:-${USER}}/$args$(date "+%Y-%b-%d"); args=$(echo "$args" | tr ' [A-Z]' '_[a-z]'); git checkout -b "$args"; };fAn alias to delete a branch:
alias.rmbr !f(){ git branch -d "${1}"; git push origin --delete "${1}"; };fAn alias to go to master:
alias.master checkout masterAn alias to get coffee:
alias.coffee !f(){ if [ $(date -j +%a) = 'Fri' ]; then echo 'Friday! Time for beer!'; else echo 'Time for a coffee break. Go get a cup of joe.'; fi };fAn alias for a quick status:
alias.st status -s -unoAn alias to do a diff with my configured difftool:
alias.d difftoolAn alias to use kdiff3 to display my changes in my branch from master:
alias.d3master difftool --tool kdiff3 --dir-diff origin/master..A bash shell alias to do a git log of just the branch's first parent:
alias log=git log --pretty=oneline --graph --max-count=$(( $LINES / 2 )) --first-parent --use-mailmap --date=format:%Y-%b-%d\ %H:%M --pretty=format:'\''%C(red)%h%C(reset) -%C(yellow)%d%C(reset) %C(green)%cd %C(bold blue)%aN%C(reset) %s'\'' --abbrev-commitI'd suggest dropping the
-jon yourdatecommand. It doesn't need to be there because you're not setting a date, and it's not compatible with GNU date, so it won't work on 99% of servers.