Last active
May 30, 2023 06:46
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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