summaryrefslogtreecommitdiffstats
path: root/git-push.html
diff options
context:
space:
mode:
authorJunio C Hamano <junio@hera.kernel.org>2009-08-13 01:23:00 +0000
committerJunio C Hamano <junio@hera.kernel.org>2009-08-13 01:23:00 +0000
commit27a128bdf7d0ab4b37022233ba5ae84a8ebd605f (patch)
tree899c40ef171884bcc7c8db4a798e44c506bed715 /git-push.html
parent9f88386765adc1aacb4a0e3b488c69cffc59ca70 (diff)
downloadgit-htmldocs-27a128bdf7d0ab4b37022233ba5ae84a8ebd605f.tar.gz
Autogenerated HTML docs for v1.6.4-122-g6ffd7
Diffstat (limited to 'git-push.html')
-rw-r--r--git-push.html74
1 files changed, 73 insertions, 1 deletions
diff --git a/git-push.html b/git-push.html
index a73ea4c95..a43852eaa 100644
--- a/git-push.html
+++ b/git-push.html
@@ -791,6 +791,78 @@ reason
</dd>
</dl></div>
</div>
+<h2 id="_note_about_fast_forwards">Note about fast-forwards</h2>
+<div class="sectionbody">
+<div class="para"><p>When an update changes a branch (or more in general, a ref) that used to
+point at commit A to point at another commit B, it is called a
+fast-forward update if and only if B is a descendant of A.</p></div>
+<div class="para"><p>In a fast-forward update from A to B, the set of commits that the original
+commit A built on top of is a subset of the commits the new commit B
+builds on top of. Hence, it does not lose any history.</p></div>
+<div class="para"><p>In contrast, a non-fast-forward update will lose history. For example,
+suppose you and somebody else started at the same commit X, and you built
+a history leading to commit B while the other person built a history
+leading to commit A. The history looks like this:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>
+ B
+ /
+ ---X---A
+</tt></pre>
+</div></div>
+<div class="para"><p>Further suppose that the other person already pushed changes leading to A
+back to the original repository you two obtained the original commit X.</p></div>
+<div class="para"><p>The push done by the other person updated the branch that used to point at
+commit X to point at commit A. It is a fast-forward.</p></div>
+<div class="para"><p>But if you try to push, you will attempt to update the branch (that
+now points at A) with commit B. This does _not_ fast-forward. If you did
+so, the changes introduced by commit A will be lost, because everybody
+will now start building on top of B.</p></div>
+<div class="para"><p>The command by default does not allow an update that is not a fast-forward
+to prevent such loss of history.</p></div>
+<div class="para"><p>If you do not want to lose your work (history from X to B) nor the work by
+the other person (history from X to A), you would need to first fetch the
+history from the repository, create a history that contains changes done
+by both parties, and push the result back.</p></div>
+<div class="para"><p>You can perform "git pull", resolve potential conflicts, and "git push"
+the result. A "git pull" will create a merge commit C between commits A
+and B.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>
+ B---C
+ / /
+ ---X---A
+</tt></pre>
+</div></div>
+<div class="para"><p>Updating A with the resulting merge commit will fast-forward and your
+push will be accepted.</p></div>
+<div class="para"><p>Alternatively, you can rebase your change between X and B on top of A,
+with "git pull --rebase", and push the result back. The rebase will
+create a new commit D that builds the change between X and B on top of
+A.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>
+ B D
+ / /
+ ---X---A
+</tt></pre>
+</div></div>
+<div class="para"><p>Again, updating A with this commit will fast-forward and your push will be
+accepted.</p></div>
+<div class="para"><p>There is another common situation where you may encounter non-fast-forward
+rejection when you try to push, and it is possible even when you are
+pushing into a repository nobody else pushes into. After you push commit
+A yourself (in the first picture in this section), replace it with "git
+commit --amend" to produce commit B, and you try to push it out, because
+forgot that you have pushed A out already. In such a case, and only if
+you are certain that nobody in the meantime fetched your earlier commit A
+(and started building on top of it), you can run "git push --force" to
+overwrite it. In other words, "git push --force" is a method reserved for
+a case where you do mean to lose history.</p></div>
+</div>
<h2 id="_examples">Examples</h2>
<div class="sectionbody">
<div class="vlist"><dl>
@@ -936,7 +1008,7 @@ by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2009-07-09 16:48:59 UTC
+Last updated 2009-08-13 01:22:27 UTC
</div>
</div>
</body>