我正在寻找我希望的简单的一行命令来确定当前检出的分支的正确上游引用?
基本上是这样的
git branch --remote HEAD
哪个(如果有效)将符号模式HEAD转换为当前分支名称,然后该选项--remote
将其更改为远程跟踪分支的ref.(但它没有那样做!)
如果我有morehelp
一个配置的分支
remote = origin
merge = refs/heads/morehelp
Run Code Online (Sandbox Code Playgroud)
简单的命令行将返回refs/remotes/origin/morehelp
它的上游跟踪分支(适用于git reset --hard <ref>
通过覆盖更新的情况)
Jon*_*ely 15
我想你想要的
git rev-parse --symbolic-full-name @{u}
Run Code Online (Sandbox Code Playgroud)
@{u}
是上游跟踪分支的缩写,HEAD
并且选项告诉rev-parse
您以所需的格式打印它,而不是打印SHA提交ID.
从 git help rev-parse
--symbolic
Usually the object names are output in SHA1 form (with possible ^ prefix); this option makes them output in a form as close to the original
input as possible.
--symbolic-full-name
This is similar to --symbolic, but it omits input that are not refs (i.e. branch or tag names; or more explicitly disambiguating
"heads/master" form, when you want to name the "master" branch when there is an unfortunately named tag "master"), and show them as full
refnames (e.g. "refs/heads/master").
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
927 次 |
最近记录: |