Skip to content

Instantly share code, notes, and snippets.

@pmiossec
pmiossec / export_stashes.sh
Created August 1, 2022 08:43
Export all git Stashes
mkdir stashes
refs=$(git stash list|cut -d: -f1)
for ref in $refs; do git stash show "$ref" -p > ./stashes/$ref.patch; done
#refs=$(git rev-parse $refs|tac)
#oldpath=$PWD
@pmiossec
pmiossec / my git aliases
Last active May 30, 2023 06:46
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 $*\"