git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git stash path/to/only/one/subdirectory
@ 2010-12-08 14:15 Patrick Doyle
  2010-12-08 15:38 ` Johan Herland
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Doyle @ 2010-12-08 14:15 UTC (permalink / raw)
  To: git

Looking at the man page for git-stash, it seems like I can do this
with the --patch option to git-stash, but I figured I'd ask the
questions anyway...

Is it possible to git-stash a single directory, while leaving the rest
of my working copy in the state it's in?

In my particular case (as of 9:00am this morning), I've realized that
I want to split my work into 2 separate commits; I'm not done with
either of them yet; and they are in completely separate directories
from each other.  I would like to do something like:

$ git stash --subdir-only dir1
edit/test stuff in dir2, possibly committing once or twice along the way
$ git commit dir2
go off and do other stuff for a while, and come back to the dir1 stuff
I was playing with
$ git stash pop
finish the dir1 work
$ git commit dir1

If this capability doesn't exist, I could try adding it... would other
folks see this as useful?

--wpd

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git stash path/to/only/one/subdirectory
  2010-12-08 14:15 git stash path/to/only/one/subdirectory Patrick Doyle
@ 2010-12-08 15:38 ` Johan Herland
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Herland @ 2010-12-08 15:38 UTC (permalink / raw)
  To: Patrick Doyle; +Cc: git

On Wednesday 08 December 2010, Patrick Doyle wrote:
> Looking at the man page for git-stash, it seems like I can do this
> with the --patch option to git-stash, but I figured I'd ask the
> questions anyway...
>
> Is it possible to git-stash a single directory, while leaving the
> rest of my working copy in the state it's in?
>
> In my particular case (as of 9:00am this morning), I've realized that
> I want to split my work into 2 separate commits; I'm not done with
> either of them yet; and they are in completely separate directories
> from each other.  I would like to do something like:
>
> $ git stash --subdir-only dir1
> edit/test stuff in dir2, possibly committing once or twice along the
> way $ git commit dir2
> go off and do other stuff for a while, and come back to the dir1
> stuff I was playing with
> $ git stash pop
> finish the dir1 work
> $ git commit dir1

Usually, I solve these problems by staging dir2 with 'git add dir2' and 
then committing it ('git commit' without -a), then running 'git stash' 
to remove dir1 changes from the worktree. I can now test the dir2 
changes and fix the dir2 commit (if needed) with 'git commit --amend'. 
Then, when it looks good, I can bring dir1 back with 'git stash pop' 
and continue working on that.

You should also look at 'git add -p' to stage changes hunk-by-hunk. That 
is really helpful when dir1 changes and dir2 changes are not in 
separate directories.


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-08 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-08 14:15 git stash path/to/only/one/subdirectory Patrick Doyle
2010-12-08 15:38 ` Johan Herland

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