Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

git - 如何在Git中获取当前的分支名称?(How to get the current branch name in Git?)

I'm from a Subversion background and, when I had a branch, I knew what I was working on with "These working files point to this branch".

(我来自Subversion的背景,当我有一个分支时,我知道我正在使用“这些工作文件指向此分支”的内容。)

But with Git I'm not sure when I am editing a file in NetBeans or Notepad++, whether it's tied to the master or another branch.

(但是使用Git时,我不确定在NetBeans或Notepad ++中编辑文件时,是将文件绑定到主文件还是其他分支。)

There's no problem with git in bash, it tells me what I'm doing.

(bash中的git没问题,它告诉我我在做什么。)

  ask by mike628 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To display the current branch you're on, without the other branches listed, you can do the following:

(要显示当前所在的分支,而未列出其他分支,可以执行以下操作:)

git rev-parse --abbrev-ref HEAD

Reference:

(参考:)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...