command to determine the upstream ref of the current HEAD?

可紊 提交于 2019-12-04 03:16:31

I think you want

git rev-parse --symbolic-full-name @{u}

@{u} is the abbreviation for the upstream tracking branch of HEAD and the option tells rev-parse to print it in the format you want, rather than printing an SHA commit ID.

From 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").
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!