summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgit-stash25
1 files changed, 25 insertions, 0 deletions
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