Re: git-stash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> wrote:
> I just was in the need for git-stash (for the 1e6th time this year), but 
> instead of writing a script, I though I'd try the "!" convention for 
> aliases. Works quite well for me:

I have scripts saving and restoring the current state of the working
tree in the current branch using two commits: one is the current index
and the other one the index after adding all changes.

% tail -n 1000 save restore
==> save <==
#!/bin/sh
set -e
die() { echo "$0: $*" >&2; exit 1; }

parent=$(git rev-parse HEAD^0 2> /dev/null) || die requires at least one commit
tree=$(git write-tree)
commit=$(echo wip index | git commit-tree $tree -p $parent)

git diff-files --name-only -z | git update-index --remove -z --stdin
tree=$(git write-tree)
commit=$(echo wip working tree | git commit-tree $tree -p $commit)

git update-ref -m 'wip save' HEAD $commit
echo saved wip

==> restore <==
#!/bin/sh
set -e
die() { echo "$0: $*" >&2; exit 1; }

p=$(git rev-parse HEAD~1) || die requires at least 3 commits
pp=$(git rev-parse HEAD~2) || die requires at least 3 commits
git-read-tree --reset $p

git update-ref -m 'wip restore' HEAD $pp
echo restored wip
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux