{"thread":{"id":"23955","subject":"Commit to other branch","startedAt":"2010-05-31T15:46:09Z","lastAt":"2010-06-06T18:43:34Z","messageCount":4,"participants":["Johannes Schneider","Matthieu Moy","Jeff King","Jan Hudec"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"142617","messageId":"4C03D9C1.1060404@cedarsoft.com","threadId":"23955","inReplyTo":null,"subject":"Commit to other branch","fromName":"Johannes Schneider","fromEmail":"mailings@cedarsoft.com","sentAt":"2010-05-31T15:46:09Z","receivedAt":"2010-05-31T15:46:09Z","isPatch":false,"sender":{"key":"mailings@cedarsoft.com","avatar":null},"body":"Hi guys,\n\nI often run in that scenario:\nI see a small bugfix/typo/missing documentation. Of course I just add a\nbit of code to fix that issue...\nThen I'd like to commit that change as own commit. And most of the time\nthis is possible without any problems (git commit <file>).\nBut as I am *always* working on a topic branch, it takes some work to\ncommit that change to another branch.\n\nI tried to \"git stash \"\nBut then *all* changes are stashed (including my changes)...\n\nSo at the moment I do that:\n\ngit commit <file> (on wrong branch)\ngit stash\ngit checkout pu\ngit cherry-pick\ngit checkout my-topic\ngit reset --hard\ngit stash apply\n\nAnd that is much to much work. I just want to do something like that:\n\ngit commit <file> -b pu\n\nBut I don't think that is possible at the moment... Any hints, how I\ncould solve that? How do you do that?\n\n\nThanks,\n\nJohannes\n\n-- \nJohannes Schneider - blog.cedarsoft.com\n"},{"id":"142618","messageId":"vpq8w70m3wf.fsf@bauges.imag.fr","threadId":"23955","inReplyTo":"4C03D9C1.1060404@cedarsoft.com","subject":"Re: Commit to other branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-05-31T16:28:48Z","receivedAt":"2010-05-31T16:28:48Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Johannes Schneider <mailings@cedarsoft.com> writes:\n\n> I tried to \"git stash \"\n> But then *all* changes are stashed (including my changes)...\n\nNot completely answering the question, but \"git stash -k\"\n(--keep-index) allows you to do a selective stash. If you have\nrelevant changes staged, and want to commit the unstaged ones\nelsewhere, you can do something like\n\ngit stash -k\ngit checkout elsewhere\ngit commit\ngit checkout back-to-your-branch\ngit stash pop\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"142626","messageId":"20100531235016.GB13698@sigill.intra.peff.net","threadId":"23955","inReplyTo":"vpq8w70m3wf.fsf@bauges.imag.fr","subject":"Re: Commit to other branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-05-31T23:50:17Z","receivedAt":"2010-05-31T23:50:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 31, 2010 at 06:28:48PM +0200, Matthieu Moy wrote:\n\n> Johannes Schneider <mailings@cedarsoft.com> writes:\n> \n> > I tried to \"git stash \"\n> > But then *all* changes are stashed (including my changes)...\n> \n> Not completely answering the question, but \"git stash -k\"\n> (--keep-index) allows you to do a selective stash. If you have\n\nAlso, recent versions of git have \"git stash -p\" to interactively stash\njust a few changes.\n\n-Peff\n"},{"id":"143099","messageId":"20100606184334.GB30035@efreet.light.src","threadId":"23955","inReplyTo":"4C03D9C1.1060404@cedarsoft.com","subject":"Re: Commit to other branch","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2010-06-06T18:43:34Z","receivedAt":"2010-06-06T18:43:34Z","isPatch":false,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Mon, May 31, 2010 at 17:46:09 +0200, Johannes Schneider wrote:\n> I often run in that scenario:\n> I see a small bugfix/typo/missing documentation. Of course I just add a\n> bit of code to fix that issue...\n> Then I'd like to commit that change as own commit. And most of the time\n> this is possible without any problems (git commit <file>).\n> But as I am *always* working on a topic branch, it takes some work to\n> commit that change to another branch.\n\nWhat I'd probably do is just commit the quick fix, as separate commit, where\nI am. Than when I'd have a bit of time (probably when I'd otherwise think of\nrebasing on master anyway) I'd rebase -i all such fixes to the bottom of the\ntopic branch, go to master and merge just those fixes. The rebase -i can be\nagainst current master, so the merge back would be fast-forward, of course.\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"}]}