git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Making a (quick) commit to another branch

From
Javier Domingo <javierdo1@gmail.com>
Date
Apr 27, 2013, 14:21 UTC
Message-ID
<CALZVap=9Z=0DPM1fNwotn3sN-W7mXMPRSJ2aY5jzkQTBD6v=Kw@mail.gmail.com>
In-Reply-To
<517BDB6D.8040809@cedarsoft.com>
2013/4/27 Johannes Schneider <mailings@cedarsoft.com>:
Show 33 quoted lines
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi guys,
>
> I love git. And I use it every day. But there is one minor thing, that
> bugs me a little bit:
> I am implementing something on a feature branch. Now I detect a minor
> typo/bug/whatever that just needs a one line commit.
>
> But of course I don't want to add that commit to my feature branch.
> Instead I'd like to commit that fix directly to another branch (e.g.
> master).
>
> Unfortunately that take a lot of steps to make this happen:
> - - comitting
> - - stashing other changes
> - - changing branch
> - - cherry-picking commit
> - - switching branches back
> - - reverting latest commit
> - - unstashing changes
>
> I'd love to solve this by having an option for git commit that gives
> me the possibility to commit to another branch:
>
>
> git commit thefixedfile.txt -m "fixed a typo" -b master
>
>
>
> Any ideas/hints?
>

I would first recommend you, instead of cherry-picking the commit, you did this: -- stash -- go to the master branch -- fix the line -- commit the fix -- got to the feature branch -- unstash

As when you merge with master, git will carry on with the changes. I don't see the need to cherry pick that commit.

Javier Domingo
Previous: Johannes SchneiderNext: Patrik Gornicz
Message 2 of 4 in “Making a (quick) commit to another branch”
  1. Johannes SchneiderApr 27, 2013
  2. Javier DomingoApr 27, 2013
  3. Patrik GorniczApr 27, 2013
  4. Johannes SchneiderApr 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.