Re: [PATCH] git-stash.txt: Add new example

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

 



jari.aalto@xxxxxxxxx writes:

> From: Jari Aalto <jari.aalto@xxxxxxxxx>
>
> Add new example "Saving selected files to stash" thanks to
> ideas by Johan Sageryd <j416@xxxxxxx>.
>
> Signed-off-by: Jari Aalto <jari.aalto@xxxxxxxxx>
> ---
>  Documentation/git-stash.txt |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
> index 473889a..7d9f9e1 100644
> --- a/Documentation/git-stash.txt
> +++ b/Documentation/git-stash.txt
> @@ -230,6 +230,18 @@ $ edit/build/test remaining parts
>  $ git commit foo -m 'Remaining parts'
>  ----------------------------------------------------------------
>  
> +Saving selected files to stash::
> +
> +You can use `git stash save --keep-index` to put only selected files
> +into the stash. Let's suppose the files A, B, C and D are modified and
> +you want to stash only C and D:
> ++
> +----------------------------------------------------------------
> +$ git status			# Verify what's modified
> +$ git add A B			# ...not these
> +$ git stash save --keep-index   # ...but stash all the others
> +----------------------------------------------------------------
> +

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".

I'd perhaps suggest rephrasing it like this:

        Sifting the Wheat from the Chaff::

        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 ...
--
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]