Commit to other branch
Hi guys,
I often run in that scenario:
I see a small bugfix/typo/missing documentation. Of course I just add a bit of code to fix that issue...
Then I'd like to commit that change as own commit. And most of the time this is possible without any problems (git commit <file>). But as I am *always* working on a topic branch, it takes some work to commit that change to another branch.
I tried to "git stash "
But then *all* changes are stashed (including my changes)...
So at the moment I do that:
git commit <file> (on wrong branch)
git stash
git checkout pu
git cherry-pick
git checkout my-topic
git reset --hard
git stash apply
And that is much to much work. I just want to do something like that:
git commit <file> -b pu
But I don't think that is possible at the moment... Any hints, how I could solve that? How do you do that?
Thanks,
Johannes
Signature · 1 line
Johannes Schneider - blog.cedarsoft.com
Quoted 2 lines · Johannes Schneider
I tried to "git stash "
But then *all* changes are stashed (including my changes)...
Not completely answering the question, but "git stash -k" (--keep-index) allows you to do a selective stash. If you have relevant changes staged, and want to commit the unstaged ones elsewhere, you can do something like
git stash -k
git checkout elsewhere
git commit
git checkout back-to-your-branch
git stash pop
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 7 lines · Matthieu Moy
Quoted 2 lines · Johannes Schneider
I tried to "git stash "
But then *all* changes are stashed (including my changes)...Not completely answering the question, but "git stash -k" (--keep-index) allows you to do a selective stash. If you have
Also, recent versions of git have "git stash -p" to interactively stash just a few changes.
-Peff
Quoted 7 lines · Johannes Schneider
I often run in that scenario:
I see a small bugfix/typo/missing documentation. Of course I just add a bit of code to fix that issue...
Then I'd like to commit that change as own commit. And most of the time this is possible without any problems (git commit <file>). But as I am *always* working on a topic branch, it takes some work to commit that change to another branch.
What I'd probably do is just commit the quick fix, as separate commit, where I am. Than when I'd have a bit of time (probably when I'd otherwise think of rebasing on master anyway) I'd rebase -i all such fixes to the bottom of the topic branch, go to master and merge just those fixes. The rebase -i can be against current master, so the merge back would be fast-forward, of course.
Signature · 1 line
Jan 'Bulb' Hudec <[email protected]>