{"thread":{"id":"25992","subject":"git stash path/to/only/one/subdirectory","startedAt":"2010-12-08T14:15:51Z","lastAt":"2010-12-08T15:38:56Z","messageCount":2,"participants":["Patrick Doyle","Johan Herland"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"157601","messageId":"AANLkTim+sOeVfkAac1v-CsD5GG8Vj2VSjXn-9SSw+Hjb@mail.gmail.com","threadId":"25992","inReplyTo":null,"subject":"git stash path/to/only/one/subdirectory","fromName":"Patrick Doyle","fromEmail":"wpdster@gmail.com","sentAt":"2010-12-08T14:15:51Z","receivedAt":"2010-12-08T14:15:51Z","isPatch":false,"sender":{"key":"wpdster@gmail.com","avatar":null},"body":"Looking at the man page for git-stash, it seems like I can do this\nwith the --patch option to git-stash, but I figured I'd ask the\nquestions anyway...\n\nIs it possible to git-stash a single directory, while leaving the rest\nof my working copy in the state it's in?\n\nIn my particular case (as of 9:00am this morning), I've realized that\nI want to split my work into 2 separate commits; I'm not done with\neither of them yet; and they are in completely separate directories\nfrom each other.  I would like to do something like:\n\n$ git stash --subdir-only dir1\nedit/test stuff in dir2, possibly committing once or twice along the way\n$ git commit dir2\ngo off and do other stuff for a while, and come back to the dir1 stuff\nI was playing with\n$ git stash pop\nfinish the dir1 work\n$ git commit dir1\n\nIf this capability doesn't exist, I could try adding it... would other\nfolks see this as useful?\n\n--wpd\n"},{"id":"157608","messageId":"201012081638.56543.johan@herland.net","threadId":"25992","inReplyTo":"AANLkTim+sOeVfkAac1v-CsD5GG8Vj2VSjXn-9SSw+Hjb@mail.gmail.com","subject":"Re: git stash path/to/only/one/subdirectory","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2010-12-08T15:38:56Z","receivedAt":"2010-12-08T15:38:56Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Wednesday 08 December 2010, Patrick Doyle wrote:\n> Looking at the man page for git-stash, it seems like I can do this\n> with the --patch option to git-stash, but I figured I'd ask the\n> questions anyway...\n>\n> Is it possible to git-stash a single directory, while leaving the\n> rest of my working copy in the state it's in?\n>\n> In my particular case (as of 9:00am this morning), I've realized that\n> I want to split my work into 2 separate commits; I'm not done with\n> either of them yet; and they are in completely separate directories\n> from each other.  I would like to do something like:\n>\n> $ git stash --subdir-only dir1\n> edit/test stuff in dir2, possibly committing once or twice along the\n> way $ git commit dir2\n> go off and do other stuff for a while, and come back to the dir1\n> stuff I was playing with\n> $ git stash pop\n> finish the dir1 work\n> $ git commit dir1\n\nUsually, I solve these problems by staging dir2 with 'git add dir2' and \nthen committing it ('git commit' without -a), then running 'git stash' \nto remove dir1 changes from the worktree. I can now test the dir2 \nchanges and fix the dir2 commit (if needed) with 'git commit --amend'. \nThen, when it looks good, I can bring dir1 back with 'git stash pop' \nand continue working on that.\n\nYou should also look at 'git add -p' to stage changes hunk-by-hunk. That \nis really helpful when dir1 changes and dir2 changes are not in \nseparate directories.\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"}]}