git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org
Subject: git-stash
Date: Thu, 7 Jun 2007 23:28:33 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0706072328000.4046@racer.site> (raw)

Hi,

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:

git config alias.stash '!git diff-files --name-only -z | git update-index 
-z --stdin && tree=$(git-write-tree) && commit=$(echo stash $(date) | 
git-commit-tree $tree) && git-update-ref refs/heads/stash $commit && 
git-reset --hard'

(This is one long line.)

With this, I can now say "git stash" with a dirty working directory, and 
it will have the same effect as "git reset --hard", i.e. reset to the 
clean state in HEAD.

Except that all my changes are stashed away in the branch "stash". It is 
not really a branch, as I expect it to jump from loose end to loose end, 
like this:

A - B - C - D - E - F - G - H - ...  (master branch)
  \               \       \
    A'  ..          E'  ..  G'       (stash branch)

The ".." denote reflog connections: "git log stash" will show G' and as 
its parent G with its history, while "git reflog stash" will show G', and 
then E', and then A'.

Maybe it is not only useful for me...

Ciao,
Dscho

             reply	other threads:[~2007-06-07 22:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-07 22:28 Johannes Schindelin [this message]
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 ` git-stash Matthias Lederhofer

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=Pine.LNX.4.64.0706072328000.4046@racer.site \
    --to=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).