Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Update 2015</p> <p>My initial answer below is not ideal as the upstream branch is not necessarily the branch you are pushing to. It is only the branch you are pulling from.</p> <p>With Git 2.5+, the correct command is:</p> <pre><code>git for-each-ref --format="%(refname:short) %(upstream:track)" refs/heads </code></pre> <p>See more at "<a href="https://stackoverflow.com/a/30720302/6309">Viewing Unpushed Git Commits</a>".</p> <p>(as pointed out by <a href="https://stackoverflow.com/users/157971/void-pointer">void.pointer</a> in <a href="https://stackoverflow.com/questions/7773939/show-git-ahead-and-behind-info-for-all-branches-including-remotes/20499690#comment75001066_20499690">the comments</a>, <code>upstream:track</code> is more precise than <code>push:track</code>, depending on the <a href="https://stackoverflow.com/a/6547682/6309">default push policy</a>)</p> <hr> <p>Git 2.13 (Q2 2017) uses a more generic ref-filter API with a more complete <a href="https://github.com/git/git/blob/93e8cd8b6ee766b35bfd3913f56ba86d63cb6253/Documentation/git-for-each-ref.txt#L141-L146" rel="noreferrer"><code>git for-each-ref push</code></a>:</p> <p>See <a href="https://github.com/git/git/commit/3d9e4ce3ebef4f5aa47dad49f730e085f32b98da" rel="noreferrer">commit 3d9e4ce</a>, <a href="https://github.com/git/git/commit/949af0684c1f84587504e2143fca6f9bb8504e31" rel="noreferrer">commit 949af06</a>, <a href="https://github.com/git/git/commit/56b43607f975841e70203e55bba3c0b0228da6b0" rel="noreferrer">commit 56b4360</a>, <a href="https://github.com/git/git/commit/6eac70fa6343a31b5b310a465a442adb6731a26b" rel="noreferrer">commit 6eac70f</a>, <a href="https://github.com/git/git/commit/1a34728e6bb469083dd46ff35362fdfc6e489d07" rel="noreferrer">commit 1a34728</a>, <a href="https://github.com/git/git/commit/1a0ca5e358c1af14160e610e346c706e5dccf535" rel="noreferrer">commit 1a0ca5e</a>, <a href="https://github.com/git/git/commit/3a42980f9e5ecc2b74c538109d4007c630881f1c" rel="noreferrer">commit 3a42980</a>, <a href="https://github.com/git/git/commit/17938f171f703c28696c7839a910565f0fb32121" rel="noreferrer">commit 17938f1</a>, <a href="https://github.com/git/git/commit/3ba308cb4b4ad0d06fa834a42a9380c877b0c16a" rel="noreferrer">commit 3ba308c</a>, <a href="https://github.com/git/git/commit/a7984101846ccfb8837526a8d79dda5b8c461d84" rel="noreferrer">commit a798410</a>, <a href="https://github.com/git/git/commit/b180e6fe19ee4cf701d3a3478025dd7125fb0749" rel="noreferrer">commit b180e6f</a>, <a href="https://github.com/git/git/commit/01f95825d55b2ca36ee9bc131a5f6899f47621c6" rel="noreferrer">commit 01f9582</a>, <a href="https://github.com/git/git/commit/7743fcca5be6854a1b9a5a0f7e60b79c15fee4b9" rel="noreferrer">commit 7743fcc</a>, <a href="https://github.com/git/git/commit/ffd921d311c9293ce83e0d191769a962d9197a71" rel="noreferrer">commit ffd921d</a>, <a href="https://github.com/git/git/commit/99c6a71d4f7f4197f5e8600b0edec2a6a9fd9988" rel="noreferrer">commit 99c6a71</a>, <a href="https://github.com/git/git/commit/d4919bb288e46c81b92d6fe02c4f4564b8477fd3" rel="noreferrer">commit d4919bb</a>, <a href="https://github.com/git/git/commit/42d0eb05eed8e6c66d93091f5b0ece3a1872246c" rel="noreferrer">commit 42d0eb0</a>, <a href="https://github.com/git/git/commit/4f3e3b37fae818e0e370d14fd56479d3a7d68b6e" rel="noreferrer">commit 4f3e3b3</a>, <a href="https://github.com/git/git/commit/c58fc85692d759cb33a59e138a94931044a08284" rel="noreferrer">commit c58fc85</a> (10 Jan 2017) by <a href="https://github.com/KarthikNayak" rel="noreferrer">Karthik Nayak (<code>KarthikNayak</code>)</a>.<br> <sup>(Merged by <a href="https://github.com/gitster" rel="noreferrer">Junio C Hamano -- <code>gitster</code> --</a> in <a href="https://github.com/git/git/commit/93e8cd8b6ee766b35bfd3913f56ba86d63cb6253" rel="noreferrer">commit 93e8cd8</a>, 27 Feb 2017)</sup> </p> <pre><code>push: </code></pre> <blockquote> <p>The name of a local ref which represents the <code>@{push}</code> location for the displayed ref.<br> Respects <code>:short</code>, <code>:lstrip</code>, <code>:rstrip</code>, <code>:track</code>, and <code>:trackshort</code> options as <code>upstream</code> does.<br> Produces an empty string if no <code>@{push}</code> ref is configured.</p> <p>If <code>lstrip=&lt;N&gt;</code> (<code>rstrip=&lt;N&gt;</code>) is appended, strips <code>&lt;N&gt;</code> slash-separated path components from the front (back) of the refname<br> (e.g. <code>%(refname:lstrip=2)</code> turns <code>refs/tags/foo</code> into <code>foo</code> and <code>%(refname:rstrip=2)</code> turns <code>refs/tags/foo</code> into <code>refs</code>).</p> <p>If <code>&lt;N&gt;</code> is a negative number, strip as many path components as necessary from the specified end to leave <code>-&lt;N&gt;</code> path components<br> (e.g. <code>%(refname:lstrip=-2)</code> turns <code>refs/tags/foo</code> into <code>tags/foo</code> and <code>%(refname:rstrip=-1)</code> turns <code>refs/tags/foo</code> into <code>refs</code>)</p> </blockquote> <hr> <p>Original answer (2014)</p> <p>Another way will be available with Git 1.9/2/0 (Q1 2014).<br> See <a href="https://github.com/git/git/commit/b28061ce0d2e31d390fee5a5724b8a061d0492a7" rel="noreferrer">commit b28061c</a> from <a href="https://github.com/artagnon" rel="noreferrer">Ramkumar Ramachandra (artagnon)</a>:</p> <h2><code>for-each-ref</code>: introduce <code>%(upstream:track[short])</code></h2> <blockquote> <p>Introduce:</p> <ul> <li><code>%(upstream:track)</code> to display "<code>[ahead M, behind N]</code>" and</li> <li><code>%(upstream:trackshort)</code> to display "<code>=</code>", "<code>&gt;</code>", "<code>&lt;</code>", or "<code>&lt;&gt;</code>" appropriately (inspired by <a href="https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh" rel="noreferrer"><code>contrib/completion/git-prompt.sh</code></a>).</li> </ul> <p>Now you can use the following format in for-each-ref:</p> </blockquote> <pre><code>%(refname:short) %(upstream:trackshort) </code></pre> <blockquote> <p>to display refs with terse tracking information.</p> <p>Note that <code>:track</code> and <code>:trackshort</code> only work with "<code>upstream</code>", and error out when used with anything else.</p> </blockquote>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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