Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>pull vs fetch</em>:</p> <p>The way I understand this, is that <code>git pull</code> is simply a <code>git fetch</code> followed by <code>git merge</code>. I.e. you fetch the changes from a remote branch and then merge it into the current branch.</p> <hr> <p><em>merge vs rebase</em>:</p> <p>A merge will do as the command says; merge the differences between current branch and the specified branch (into the current branch). I.e. the command <code>git merge another_branch</code> will the merge <code>another_branch</code> into the current branch.</p> <p>A rebase works a bit differently and is kind of cool. Let's say you perform the command <code>git rebase another_branch</code>. Git will first find the latest common version between the current branch and <code>another_branch</code>. I.e. the point before the branches diverged. Then git will move this divergent point to the head of the <code>another_branch</code>. Finally, all the commits in the current branch since the original divergent point are <em>replayed</em> from the new divergent point. This creates a very clean history, with fewer branches and merges.</p> <p>However, it is not without pitfalls! Since the version history is "rewritten", you should only do this if the commits only exists in your local git repo. That is: <em>Never</em> do this if you have pushed the commits to a remote repo.</p> <p>The explanation on rebasing given in <a href="http://git-scm.com/book/en/Git-Branching-Rebasing" rel="noreferrer">this</a> online book is quite good, with easy-to-understand illustrations.</p> <hr> <p><em>pull with rebasing instead of merge</em></p> <p>I'm actually using rebase quite a lot, but usually it is in combination with pull:</p> <pre><code>git pull --rebase </code></pre> <p>will fetch remote changes and then rebase instead of merge. I.e. it will replay all your local commits from the last time you performed a pull. I find this much cleaner than doing a normal pull with merging, which will create an extra commit with the merges.</p>
 

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