From: Jari Aalto <jari.aalto@cante•net>
To: Junio C Hamano <gitster@pobox•com>
Cc: git@vger•kernel.org
Subject: [PATCH v2] git-stash.txt: Add example "Using stash selectively"
Date: Thu, 06 May 2010 11:40:52 +0300 [thread overview]
Message-ID: <87pr194e3v.fsf_-_@jondo.cante.net> (raw)
In-Reply-To: <7v39y6jfmv.fsf@alter.siamese.dyndns.org>
Add a new example to demonstrate the use of --keep-index.
Idea by Johan Sageryd <j416@1616•se>.
Signed-off-by: Jari Aalto <jari.aalto@cante•net>
---
Documentation/git-stash.txt | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
> While the above is not _wrong_ per-se, it was somewhat hard to understand
> for me without a description on _why_ you might want to do this. It
> didn't help that "put only selected files" really meant "get rid of
> selected _changes_ from the working tree and the index temporarily".
This demonstrates the difference between the end-user and developer. The
end-used think in term of tangible objects: "I have files, I need to
stash some of them".
> I'd perhaps suggest rephrasing it like this:
>
> Sifting the Wheat from the Chaff::
As a non-native, to my regret, I'm unable to compherend this Heading, my
suggestion in patch v2:
"Using stash selectively"
> When you have changes to the working tree that mix what are
> necessary for the immediate task at hand, and what are needed
> later but not right now, you can first `git add` only the former
> and use `git stash save --keep-index` to get rid of the latter.
> The latter is temporarily stored in the stash.
>
> Suppose you have changes to file A, B, and C, but only the half of
> changes to file A and C are necessary for what you are doing:
>
> $ git reset # make the index clean
> $ git add -p A C # add necessary bits to the index
> $ git stash save --keep-index # the remainder goes to the stash
> ... test, debug, perfect ...
> $ git commit
> $ git stash pop # get the remainder back
> ... and continue to work ...
I've rewritten the patch based on the comments. Please review.
Jari
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 473889a..b3fa1e7 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -243,6 +243,22 @@ grep commit | cut -d\ -f3 |
xargs git log --merges --no-walk --grep=WIP
----------------------------------------------------------------
+Using stash selectively::
+
+The `--keep-index` option can be useful in a situation where you want
+store some, but not all, files temporarily in the stash. Suppose you
+have changes to file A, B, and C, but only the half of changes to file
+A and C are necessary for what you are doing:
++
+----------------------------------------------------------------
+$ git reset # make the index clean
+$ git add -p A C # add necessary bits to the index
+$ git stash save --keep-index # the remainder goes to the stash
+... test, debug, perfect ...
+$ git commit
+$ git stash pop # get the remainder back
+... and continue to work ...
+----------------------------------------------------------------
SEE ALSO
--------
--
1.7.0
next prev parent reply other threads:[~2010-05-06 8:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 7:37 [PATCH] git-stash.txt: Add new example jari.aalto
2010-05-05 19:46 ` Junio C Hamano
2010-05-06 8:40 ` Jari Aalto [this message]
2010-05-06 9:04 ` [PATCH v2] git-stash.txt: Add example "Using stash selectively" Johannes Sixt
2010-05-07 8:50 ` [PATCH v3] " Jari Aalto
2010-05-07 16:11 ` [PATCH v2] " Junio C Hamano
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=87pr194e3v.fsf_-_@jondo.cante.net \
--to=jari.aalto@cante$(echo .)net \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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