@ {push}与@ {u}或跟踪分支有什么不同?

时间:2015-08-20 00:03:09

标签: git

根据Git 2.5.0发行说明:

  

新的短手<branch>@{push}表示远程跟踪分支,它跟踪将被推送到的远程分支。

如果设置了正确的跟踪分支,这与<branch>@{u}(对于上游分支)有什么不同,甚至只是在没有参数的情况下进行$ git push

1 个答案:

答案 0 :(得分:2)

以下是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.

因此,如果您的上游跟踪分支位于与您默认配置为推送到的远程不同的远程分支上,则它们会有所不同。