Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A shortcut, which doesn't depend on remembering the syntax for <code>git branch --set-upstream</code> <sup>1</sup> is to do:</p> <pre><code>git push -u origin my_branch </code></pre> <p>... the first time that you push that branch. Or, to push to the current branch to a branch of the same name (handy for an alias):</p> <pre><code>git push -u origin HEAD </code></pre> <p>You only need to use <code>-u</code> once, and that sets up the association between your branch and the one at <code>origin</code> in the same way as <code>git branch --set-upstream</code> does.</p> <p>Personally, I think it's a good thing to have to set up that association between your branch and one on the remote explicitly. It's just a shame that the rules are <a href="http://longair.net/blog/2011/02/27/an-asymmetry-between-git-pull-and-git-push/" rel="nofollow noreferrer">different for <code>git push</code> and <code>git pull</code></a>.</p> <hr> <p><sup>1</sup> It may sound silly, but I very frequently forget to specify the current branch, assuming that's the default - it's not, and the results are most confusing :)</p> <p><em>Update 2012-10-11</em>: Apparently I'm not the only person who found it easy to get wrong! Thanks to <a href="https://stackoverflow.com/users/6309/vonc">VonC</a> for pointing out that git 1.8.0 introduces the more obvious <code>git branch --set-upstream-to</code>, which can be used as follows, if you're on the branch <code>my_branch</code>:</p> <pre><code>git branch --set-upstream-to origin/my_branch </code></pre> <p>... or with the short option:</p> <pre><code>git branch -u origin/my_branch </code></pre> <p>This change, and its reasoning, is described in <a href="http://git.661346.n2.nabble.com/ANNOUNCE-Git-v1-8-0-rc1-tc7568792.html" rel="nofollow noreferrer">the release notes for git 1.8.0, release candidate 1</a>:</p> <blockquote> <p>It was tempting to say <code>git branch --set-upstream origin/master</code>, but that tells Git to arrange the local branch <code>origin/master</code> to integrate with the currently checked out branch, which is highly unlikely what the user meant. The option is deprecated; use the new <code>--set-upstream-to</code> (with a short-and-sweet <code>-u</code>) option instead.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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