Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 342723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:49:52+00:00 2026-05-12T10:49:52+00:00

I have a couple of Git branches: ‘experimental’, ‘something’ and ‘master’. I switched to

  • 0

I have a couple of Git branches: ‘experimental’, ‘something’ and ‘master’.

I switched to the ‘experimental’ branch. I noticed a bug which is unrelated to ‘experimental’ and belongs to changes which have been made in ‘something’. How should I fix it?

I’m thinking I should switch to ‘something’, fix the bug, commit and then move back to ‘experimental’. How should I take the minor change from ‘something’ and apply it to both ‘master’ and ‘experimental’ so that I don’t have to re-fix the bug again when I switch into these branches?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:49:52+00:00Added an answer on May 12, 2026 at 10:49 am

    There are two solutions not mentioned already that you can use: use a topic branch or use cherry-picking.


    Topic branch solution

    In the topic branch solution, you switch to branch ‘something’, create a branch to fix a bug e.g. ‘something-bugfix’, merge this branch into ‘something’ (fixing the bug), then merge this branch into ‘experimental’.

    $ git checkout -b something-fix something
    [edit, commit]
    $ git checkout something
    $ git merge something-fix
    $ git checkout experimental
    $ git merge something-fix
    [fix conflicts if necessary and commit]
    

    See also Resolving conflicts/dependencies between topic branches early and Never merging back, and perhaps also Committing to a different branch blog posts by Junio C Hamano (git maintainer).


    Cherry-picking a bugfix

    The cherry-picking solution is useful if you noticed later that the bugfix you created (e.g. on development branch) would be useful also on other branch (e.g. stable branch). In your case you would comit a fix on ‘something’ branch:

    $ git checkout something
    [edit, edit, edit]
    $ git commit
    $ git checkout experimental
    

    Then you noticed that fix you comitted in ‘something’ branch should be also on ‘experimenta’ branch. Lets say that this bugfix was commit ‘A’ (e.g. ‘something’ if you didn’t commit anything on top of ‘something’, but it might be e.g. ‘something~2’ or ‘c84fb911’):

    $ git checkout experimental
    $ git cherry-pick A
    

    (you can use --edit option to git cherry-pick if you want to edit commit message before comitting cherry-picked bugfix).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a branch which has merged master to it couple of times (to
I have a git branch (called v4), that was made from master just yesterday.
I have 2 local branches called master and working. I have a couple of
I have been studding GIT for the last couple of weeks in an attempt
We have a Git repository with over 400 commits, the first couple dozen of
I have cloned a git repo which has my emacs config files in. I
We already have a couple of feature and release branches on the go that
Lets say I have a couple branches with different code: BranchA and BranchB. Assume
I have a project in git. It has a couple of submodules. Without going
I have deleted a file a couple of times in git, but it keeps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.