Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The main things that come to mind for having a local branch track another local branch are (1) more informed messages from Git regarding a branch being ahead/behind of the tracked branch and (2) trigger hooks.</p> <p>One area Git displays more information is when creating a branch. Creating a <a href="http://book.git-scm.com/3_basic_branching_and_merging.html">basic branch</a> looks like the following:</p> <pre><code>$ git co -b A master Switched to a new branch 'A' </code></pre> <p>While creating a <a href="http://book.git-scm.com/4_tracking_branches.html">tracking branch</a> looks like:</p> <pre><code>$ git co --track -b B master Branch B set up to track local branch master. Switched to a new branch 'B' </code></pre> <p>This would add the following in <code>.git/config</code>:</p> <pre><code>[branch "B"] remote = . merge = refs/heads/master </code></pre> <p>After committing some changes on branches <code>A</code> and <code>B</code>, executing <code>git status -s -b</code> on branch <code>A</code> displays <code>## A</code> while on branch <code>B</code> it displays <code>## B...master [ahead 1, behind 1]</code>, providing some quick information regarding the relationship between branches <code>B</code> and <code>master</code>.</p> <p>The other area where you might want a local branch track another local branch is to trigger <a href="http://book.git-scm.com/5_git_hooks.html">hooks</a>; in particular <code>pre-receive</code>, <code>update</code>, <code>post-receive</code> and <code>post-update</code> during a <a href="http://schacon.github.com/git/git-push.html"><code>git push</code></a>. You might have hooks to, for example, trigger a build on a continuous integration server, do some license header checks, check for white space format errors, etc.</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