通用git重置为默认上游头部 [英] Generic git reset to default upstream HEAD
问题描述
是否有语法重置为当前分支的默认上游头部?
Is there a syntax to reset to the current branch's default upstream HEAD?
类似于:
Something like:
git checkout mybranch
git reset --hard origin/mybranch
推荐答案
你想要的语法魔法是修订说明符的一部分。这些记录在 gitrevisions 中。
The syntactic magic you want is part of a "revision specifier". These are documented in gitrevisions.
附加到分支的字符串 @ {upstream}
(缩写, @ {u}
)名称,意思是解决分支到上游。如果你省略了分支名称,git会替换 HEAD
,即 HEAD @ {u}
。这使用 HEAD
来查找当前分支,然后按照您指定的那样继续。
The string @{upstream}
(abbreviation, @{u}
), appended to a branch name, means "resolve the branch to its upstream". If you omit the branch name, git substitutes in HEAD
, i.e., HEAD@{u}
. This uses HEAD
to find the current branch and then proceeds as if you had specified that.
p>
So:
git reset --hard @{u}
将会完成这项工作(当然与任何 git reset --hard
一样,小心使用)。
will do the job (of course as with any git reset --hard
, use this with care).
(在某些shell中,您可能需要引用大括号。)
(In some shells you may have to quote the braces.)
这篇关于通用git重置为默认上游头部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!