Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I use git rebase without requiring a forced push?
    primarykey
    data
    text
    <p>In an attempt to achieve git nirvana, I'm spending the day learning how to leverage rebase for situations where I currently merge.</p> <p>When running through what I consider to be a git 101 flow (which I spell out below), I have to <code>push --force</code> when pushing my changes back to the origin. </p> <p>I'm not the only one - I know that this is covered ground (see <a href="https://stackoverflow.com/questions/7163457/the-correct-way-of-git-rebase%20-%20dupe">1</a>,<a href="https://stackoverflow.com/questions/1627906/rebase-push-cycles-for-git-branches">2</a>,<a href="https://stackoverflow.com/questions/559917/git-rebase-and-git-push-non-fast-forward-why-use">3</a>,<a href="https://stackoverflow.com/questions/9661059/git-pull-rebase-upstream-git-push-origin-rejects-non-fast-forward">4</a>,<a href="https://stackoverflow.com/questions/9591141/git-rebase-on-long-lived-remote-feature-branches">5</a>), and I understand the technical reasons <em>why</em> a force is necessary. My issue is this --- there are many (many) blog entries singing the praises of rebase and how it's changed their lives (see <a href="http://blog.woobling.org/2009/05/git-rebase-considered-awesome.html" rel="noreferrer">1</a>,<a href="http://gitguru.com/2009/02/03/rebase-v-merge-in-git/" rel="noreferrer">2</a>,<a href="http://gitready.com/intermediate/2009/01/31/intro-to-rebase.html" rel="noreferrer">3</a>,<a href="http://darwinweb.net/articles/the-case-for-git-rebase" rel="noreferrer">4</a> to list a few), but none of them mentions that <code>push --force</code> is part of their flow. However, nearly every answer to the existing stackoverflow questions say things like "yeah, if you're gonna rebase, ya gotta use <code>push --force</code>".</p> <p>Given the number and religiosity of rebase advocates, <strong>I have to believe that using 'push --force' is not an inherent part of a rebase flow, and that if one often has to force their pushes, they're doing something wrong</strong>.</p> <p><code>push --force</code> is a <a href="http://www.randyfay.com/node/89" rel="noreferrer">bad thing</a>.</p> <p>So here's my flow. <strong>In what way could I achieve the same results without a force?</strong></p> <p><strong>Simple Example</strong></p> <p>Two branches:</p> <ul> <li><strong>v1.0</strong> - a release branch, contains only patches</li> <li><strong>master</strong> - everything for the next major release.</li> </ul> <p>I've got a few patch commits and a few commits for the next release.</p> <p><img src="https://i.stack.imgur.com/DA6lA.jpg" alt="premerge"></p> <p>I'd like to incorporate the patches into my master so that they're not lost for the next release. Pre-enlightenment I'd simply:</p> <pre><code>git checkout master git merge v1.0 </code></pre> <p>But now I'm trying</p> <pre><code>git checkout master git rebase v1.0 </code></pre> <p>So now I'm here:</p> <p><img src="https://i.stack.imgur.com/Yqas5.jpg" alt="enter image description here"></p> <p>Time for:</p> <pre><code>git push </code></pre> <p>No dice. </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.
 

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