[PATCH v2] git-stash.txt: Add example "Using stash selectively"

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

 



Add a new example to demonstrate the use of --keep-index.
Idea by Johan Sageryd <j416@xxxxxxx>.

Signed-off-by: Jari Aalto <jari.aalto@xxxxxxxxx>
---
 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
--
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]