gpt4 book ai didi

git - @{push} 与@{u} 或跟踪分支有何不同?

转载 作者:太空狗 更新时间:2023-10-29 13:25:28 25 4
gpt4 key购买 nike

根据 Git 2.5.0 发行说明:

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

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

最佳答案

这里是相关文档,来自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.

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

关于git - @{push} 与@{u} 或跟踪分支有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32107557/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com