From 8fc4fdce522bb67bdf72a1fb1961927eb3c26ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 31 Jul 2012 11:38:03 +0200 Subject: add git-stash --- git-stash | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 git-stash diff --git a/git-stash b/git-stash new file mode 100755 index 0000000..5fc028f --- /dev/null +++ b/git-stash @@ -0,0 +1,25 @@ +#! /bin/bash +# +# very clever trick found there https://github.com/sitaramc/git-notes/blob/master/2-command-line-usage/git-tasks.mkd +# +# initial values: R (repo), I (index), C (changed), and U (untracked) +# notation: repo contents/index contents/work tree contents +# +option=${1:-""} +if [ "$option" = "-u" ] ; then + echo -e "\033[0;31mgit un-stash\033[0m" + # now RICU/RICU/RICU + git reset --mixed HEAD^ # repo=index=R+I + # now RI/RI/RICU; moved HEAD and index back one step + git reset --soft HEAD^ + # now R/RI/RICU; moved HEAD back one more step +else + echo -e "\033[0;31mgit stash\033[0m" + # R/RI/RICU; start + git commit --allow-empty -m wip-index-state + # now RI/RI/RICU; pushed index onto repo + git add -A && git commit --allow-empty -m wip-worktree-state + # now RICU/RICU/RICU; pushed C/U files onto repo + # ... switch branch, work work work, commit ... + # now you want to get back to the saved state +fi -- cgit v1.1-2-g2b99