Git分支不返回任何结果 [英] Git branch not returning any results
本文介绍了Git分支不返回任何结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试查看我在哪个分支上,但是它不起作用...
I'm trying to see what branch I'm on, but its not working...
$ git checkout -b test
Switched to a new branch 'test'
$ git branch
$ git branch -a
$
推荐答案
这是因为您尚未提交任何内容,因此当您执行git checkout -b test
时,git会将.git/HEAD
文件的内容从ref: refs/heads/master
修改为ref: refs/heads/test
,实际上什么也没指向.只有在您提交后,git才会为您创建test
引用,您会发现一个.git/refs/heads/test
文件,其中包含您刚刚进行的提交的哈希值.
That's because you have not yet committed anything, when you do git checkout -b test
, git modifies content of the .git/HEAD
file from ref: refs/heads/master
to ref: refs/heads/test
, which actually points to nothing. Only after you make a commit will git create the test
refs for you and you will find a .git/refs/heads/test
file, which contains the hash of the commit you just made.
这篇关于Git分支不返回任何结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文