Switching branch before commit

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Switching branch before commit

From: Ron Parker <hidden>
Date: 2016-06-15 22:43:09

I know this is probably a FAQ and I thought I found it somewhere once,
but... How do I commit changes from in my working directory to another
(possibly non-existent) branch?
 
All too often I am working on changes and realize I am sitting on master
or a topic branch and I need to commit my mods to different branch.  I
really don't like:
 
    git commit
    git branch <other-branch>
    git reset --hard HEAD^
 
Is there anything like:
    git commit -b <other-branch> [<file>...]?

If not, would patches to implement such a change be accepted?

Re: Switching branch before commit

From: Adam Roben <hidden>
Date: 2016-06-15 22:43:09

On May 10, 2007, at 12:43 PM, Ron Parker wrote:
I know this is probably a FAQ and I thought I found it somewhere once,
but... How do I commit changes from in my working directory to another
(possibly non-existent) branch?

All too often I am working on changes and realize I am sitting on  
master
or a topic branch and I need to commit my mods to different branch.  I
really don't like:

   git commit
   git branch <other-branch>
   git reset --hard HEAD^

Is there anything like:
   git commit -b <other-branch> [<file>...]?

If not, would patches to implement such a change be accepted?
    You can do this simply by doing the following:

git checkout -b <other-branch>
git commit

    The changes in your working tree will be carried over to <other- 
branch> when you do the git-checkout command.

-Adam
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help