Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is @{push} different from @{u} or a tracking branch?

Tags:

git

According to Git 2.5.0 release notes:

A new short-hand <branch>@{push} denotes the remote-tracking branch that tracks the branch at the remote the would be pushed to.

How is this different from <branch>@{u} (for upstream branch), or even just doing $ git push with no parameters when a proper tracking branch is set?

like image 540
void.pointer Avatar asked Oct 31 '22 21:10

void.pointer


1 Answers

Here is the relevant documentation, from git help rev-parse:

       <branchname>@{push}, e.g. master@{push}, @{push}
       The suffix @{push} reports the branch "where we would push to" if
       git push were run while branchname was checked out (or the current
       HEAD if no branchname is specified). Since our push destination is
       in a remote repository, of course, we report the local tracking
       branch that corresponds to that branch (i.e., something in
       refs/remotes/).

       Here's an example to make it more clear:

           $ git config push.default current
           $ git config remote.pushdefault myfork
           $ git checkout -b mybranch origin/master

           $ git rev-parse --symbolic-full-name @{upstream}
           refs/remotes/origin/master

           $ git rev-parse --symbolic-full-name @{push}
           refs/remotes/myfork/mybranch

       Note in the example that we set up a triangular workflow, where we
       pull from one location and push to another. In a non-triangular
       workflow, @{push} is the same as @{upstream}, and there is no need
       for it.

So, they will be different if your upstream tracking branch is on a different remote than the one you've configured to push to by default.

like image 168
amalloy Avatar answered Nov 15 '22 06:11

amalloy