From: Matthias Lederhofer <matled@gmx.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: git-stash
Date: Fri, 8 Jun 2007 08:52:45 +0200 [thread overview]
Message-ID: <20070608065245.GA27863@moooo.ath.cx> (raw)
In-Reply-To: <Pine.LNX.4.64.0706072328000.4046@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> 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
prev parent reply other threads:[~2007-06-08 6:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-07 22:28 git-stash Johannes Schindelin
2007-06-07 22:52 ` git-stash Lars Hjemli
2007-06-07 22:55 ` git-stash Johannes Schindelin
2007-06-07 23:38 ` git-stash Lars Hjemli
2007-06-08 0:26 ` git-stash Bill Lear
2007-06-08 6:52 ` Matthias Lederhofer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070608065245.GA27863@moooo.ath.cx \
--to=matled@gmx.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).