Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to keep up to date with a parent branch of a remote branch
    primarykey
    data
    text
    <p>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:</p> <pre><code>git checkout topic git rebase master </code></pre> <p>However, if topic is remote branch then it seems that rebasing to master is in conflict with checking into the remote branch. </p> <p>What is the best way to keep up with changes to the master in a remote branch. </p> <p>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.</p> <p>I use the standard construct when working with remote branches:</p> <pre><code>git checkout master git checkout -b topic git push origin topic git branch --set-upstream topic origin/topic </code></pre> <p>I continue to work on topic, make commits, and push to the origin.</p> <pre><code># edit some files git commit -a git push </code></pre> <p>At some point master has been updated and I need to incorporate those changes into my topic branch.</p> <pre><code>git checkout master git pull git checkout topic git rebase master </code></pre> <p>Great. Now push that update.</p> <pre><code>$ git push To git@github.com:duane/branchtest.git ! [rejected] topic -&gt; 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. </code></pre> <p>Curiously, the log looks something like this:</p> <pre><code>$ 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. </code></pre> <p>And afterwards looks like</p> <pre><code>$ 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. </code></pre> <p>Change 1 for topic 2 was the change that I made. It is now listed twice.</p> <p>A push of course ends up with this mess on my remote topic branch.</p> <p>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!</p> <p>Where did I go wrong? How can I keep up to date with the master branch while maintaining a remote branch?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload