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

voi*_*ter 5 git

根据Git 2.5.0发行说明:

一个新的简写<branch>@{push}表示远程跟踪分支,它跟踪将被推送到的远程分支.

这与<branch>@{u}(上游分支)$ git push有什么不同,或者在设置正确的跟踪分支时,甚至只是没有参数?

ama*_*loy 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.
Run Code Online (Sandbox Code Playgroud)

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