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 6142035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:19:59+00:00 2026-05-23T18:19:59+00:00

I would like to keep a topic branch up to date with it’s parent

  • 0

I would like to keep a topic branch up to date with it’s parent branch. This works wonderfully with a local topic branch using rebase to the parent branch:

git checkout topic
git rebase master

However, if topic is remote branch then it seems that rebasing to master is in conflict with checking into the remote branch.

What is the best way to keep up with changes to the master in a remote branch.

Here is what I’ve been doing. I always seem to end up with multiple conflicts and multiple “branches” when rebasing remote branches to master.

I use the standard construct when working with remote branches:

git checkout master
git checkout -b topic
git push origin topic
git branch --set-upstream topic origin/topic

I continue to work on topic, make commits, and push to the origin.

# edit some files
git commit -a
git push

At some point master has been updated and I need to incorporate those changes into my topic branch.

git checkout master
git pull
git checkout topic
git rebase master

Great. Now push that update.

$ git push
To git@github.com:duane/branchtest.git
 ! [rejected]        topic -> topic (non-fast-forward)
error: failed to push some refs to 'git@github.com:duane/branchtest.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

Curiously, the log looks something like this:

$ git log --graph --format=oneline
* 31f4b133a4a9983528ba309e6c161e09e8061f84 Change 1 for topic 2.
* 2dc45b91856748a9c6adaf3579a7b8b2cf90a6ae Change 3 for file1.
* db97959ec75267bf94d97af6e8b2a8a762c61b25 Add topic2.txt.
* 08e6cc4b14a23dad86c2d283ee4acc1cebc775ef Change 2 for file1.
* e707b9571b2aa4d01073f156abb407fec15a195a Change 1 for file1.
* 2002670efda4d8c83150a4cc1c25fac62e37814d Add file1.txt.
* d3a6eae43e4824f455872622491c2ca861f96d4f Begin the repo.
$ git pull
Merge made by recursive.

And afterwards looks like

$ git log --graph --format=oneline
*   18ba5265e2836e1a7884341dbedb8b2cc8ab9727 Merge branch 'topic' of github.com:duane/branchtest into topic
|\  
| * 0e5f3022c7f087ed4dd70d11a0cba250300be05e Change 1 for topic 2.
* | 31f4b133a4a9983528ba309e6c161e09e8061f84 Change 1 for topic 2.
* | 2dc45b91856748a9c6adaf3579a7b8b2cf90a6ae Change 3 for file1.
|/  
* db97959ec75267bf94d97af6e8b2a8a762c61b25 Add topic2.txt.
* 08e6cc4b14a23dad86c2d283ee4acc1cebc775ef Change 2 for file1.
* e707b9571b2aa4d01073f156abb407fec15a195a Change 1 for file1.
* 2002670efda4d8c83150a4cc1c25fac62e37814d Add file1.txt.
* d3a6eae43e4824f455872622491c2ca861f96d4f Begin the repo.

Change 1 for topic 2 was the change that I made. It is now listed twice.

A push of course ends up with this mess on my remote topic branch.

An even larger problem is that this extra merge point is repeated every time a rebase to master occurs; even with no changes on master!

Where did I go wrong? How can I keep up to date with the master branch while maintaining a remote branch?

  • 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-23T18:20:00+00:00Added an answer on May 23, 2026 at 6:20 pm

    If I understand correctly, you’re wanting the remote topic branch to exactly mirror your local branch, but changes only being done on your local computer?

    In that case you should git push --force whenever you make a local change to your topic branch. However, this shouldn’t be done if you’re sharing your topic branch with anyone else. In that case, you should skip the rebase and just do a merge from master to keep up to date with it. It’s not as “pretty,” but it’s a lot more reliable.

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

Sidebar

Related Questions

I would like to be able to keep two separate branches in a git
I would like to keep the overhead at a minimum. Right now I have:
I would like to keep a static counter in a garbage collected class and
I would like to keep a list of a certain class of objects in
I would like to keep model binding when doing ajax calls from my view.
I would like to keep an item selected, on a ListView, when the user
I currently have a controller were I would like to keep track of logging
I have a small JSF app and would like to keep some state on
I'm playing with bencoding and I would like to keep bencoded strings as Java
I have various models of which I would like to keep track and collect

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.