Re: Requesting `git stash --cached` or something similar

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

 



On Mon, Apr 13, 2015 at 02:24:04PM -0700, Quinn Taylor wrote:
> I'm still fairly new to git (coming from svn) and have found `git stash` to be really useful for storing in-progress work to resume later, as one might otherwise do with diff/patch files. (With the git tools I use, I find `git stash pop` to be more convenient and reliable than creating and applying diffs, partially because the changes remained tied to my repository and easily accessible.)
> 
> Since `git stash` defaults to stashing ALL local modifications, I'd like to request there be an easy way to stash *only* the changes I've already staged in the index. (The reason I suggested --cached is due to the similarity with `git diff --cached`, but I don't doubt there would be a better name for this option.)

Ok, so this git stash --cached will save the state of the index in the
stash, and reset the index to the state in HEAD.  What happens to the
working tree?

> I tried staging everything *except* what I want to stash and using `git stash save --keep-index <message>`, but it isn't intended to support this case, and doesn't work when I have new untracked files. Instead, it stashes *all* local (tracked) changes — both staged and unstaged — but leaves the staged changes intact in the index.

What do you want this new command to do with untracked files?

I would expect the answers to be it sets the working directories state
to the state in HEAD, and leaves untracked files alone.  If that's what
you want you can do git commit -m <message>; git reset --hard; git reset
--soft; git stash save to get the effect you want I believe.  That said
it seems like a kind of odd thing to want to do, what are you actually
trying to do?

Trev

> 
> I understand that git's branching model is powerful and flexible, and that an experienced git user would generally create a private branch and commit to that, then merge the changes to mainline sometime later. However, for those like me for whom having many branches is generally more confusing than helpful, it would be fantastic to have more flexibility with `git stash`.
> 
> Thanks in advance for considering my request.
> 
> Regards,
>  - Quinn


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