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

  • Home
  • SEARCH
  • 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 3301048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:42:56+00:00 2026-05-17T20:42:56+00:00

how do I push a commit in two branches? I can’t use git push,

  • 0

how do I push a commit in two branches?

I can’t use “git push”, because then it pushes to three branches, and i just want the commit in two of them..

Ive tried a “git merge HEAD –commit id from branch A–” in branch B, but then it takes everything from branch A and merges with branch B. I just want the last commit and not everything else merged with branch B.

Anyone know what to do?

  • 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-17T20:42:57+00:00Added an answer on May 17, 2026 at 8:42 pm

    Short answer

    You can apply already existing commit to another branch using cherry-pick command, and then push both branches using git push origin branchA branchB.


    Why pushing a commit in two branches might be useful

    Assume you have a repository with this structure:

    A--B--C--D  ← master ← HEAD
          \--E  ← v1-release
    

    After some development (commits A, B, C) project was released and v1-release branch was created (so that v1 can be supported with bugfixes and next version can be developed in master). Commit E was used to specify version information (added release notes, etc). Commit D introduced new feature, which is planned for the next version and should not appear in v1-release.

    Now, if a bug is found in v1-release, it must be fixed in both branches, so that users can continue using v1 and it does not appear in the next version.

    After fixing the bug in master, repository should look like this:

    A--B--C--D--F  ← master ← HEAD
          \--E     ← v1-release
    

    Now commit F with a bugfix must be applied to v1-release branch.

    How to actually do it

    Commits cannot be exactly copied (since commit is a directory saved state), but you can apply changes made in commit to another commit.

    cherry-pick command does exactly that. It applies changes made by a specified commit to the current branch, creating new commit:

    git checkout v1-release
    git cherry-pick F
    

    After this, repository should look like this:

    A--B--C--D--F  ← master
          \--E--G  ← v1-release ← HEAD
    

    Commit G introduces same changes as F.

    You may have to resolve conflicts (exactly like after merge).

    Error message

    The previous cherry pick was now empty …

    means that changes made by cherry-picked commit are already present in current branch. You probably forgot to checkout correct branch.

    In case of errors or conflicts cherry-pick can be aborted using git cherry-pick --abort.

    Finally, you can return to master branch and push both branches to remote repository:

    git checkout master
    git push origin master v1-release
    

    Final repository structure:

    A--B--C--D--F  ← master ← HEAD
          \--E--G  ← v1-release
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What would possibly cause a 'git push' to try and commit to two branches?
I need to recover two Git branches that I somehow deleted during a push.
I have some configuration files to commit on GIT with default parameters. Users can
I have two branches: master and dev I want to create a "feature branch"
When I'm on master, I only have to type 'git push' to push commits
I want to be able to push out application updates to windows mobile 5
Basically I wanted to do something like git push mybranch to repo1, repo2, repo3
I'm writing a script that makes some trivial changes and then commits them to
So I just started using Git and GitHub. It's still a steep climb, but
first i have a file name readme then i change it to README commit

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.