Skip to content

Instantly share code, notes, and snippets.

@pmiossec
Last active May 30, 2023 06:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmiossec/5201156 to your computer and use it in GitHub Desktop.
Save pmiossec/5201156 to your computer and use it in GitHub Desktop.
Git alias to automaticaly stash (if needed) before a git command and unstash afterUsage : git s rebase master
[alias]
st = status
ci = commit
# Sync a branch with it's upstream without needed to checkout
sync = !sh -c 'git fetch upstream && git push . "upstream/$0:$0"'
syncma = sync master
#Autostash before a git command `git s rebase ....`
s = !sh -c \"git stash save | grep 'No local changes to save' && git $* || (git $* && git stash pop) \"
autostash = !sh -c \"git s $*\"
#moving between parent/child when doing a presentation
next = !git checkout -f `git rev-list --ancestry-path @..master | tail -n 1`
prev = !git checkout -f @^
#-------------- display logs-------------
#define format...
mylogbase = log --pretty=format:'%Cred%h %Cgreen%<(10,trunc)%cd %C(auto)%d%Creset%s %C(bold blue)%an' --abbrev-commit
#...and use it!
mylog = !git mylogbase --date=relative
mylogshort = !git mylogbase --date=short
#...with a graph (DAG!)
graph = !git mylog --graph
#last changes
changes = !git mylog --name-status
#users stats
statdev = shortlog -sn
###=>Standup logs ;)
#-For the user you want
standup4 = !sh -c \"git mylogbase --since='3 days' --date=short --author='$1'\"
#-For me
standup = !git standup4 `git config user.name`
#-Try to solve problem of Monday!
standupbase = !"git mylogbase --reverse --branches --date=short --since='$(if [[ "Mon" == "$(date +%a)" ]]; then echo "3 days"; else echo "yesterday"; fi)' "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment