git切换分支时报错(error: pathspec ‘master‘ did not match any file(s) known to git.)的解决方法

git切换分支时报错

切换分支:

[root@git my_code]# git checkout master

产生如下报错:

error: pathspec 'master' did not match any file(s) known to git.

解决方法:

1、查看一下分支状况:

[root@git my_code]# git branch -a
在这里插入图片描述

2、若没有看到你想要的分支,先获取全部分支:

[root@git my_code]# git fetch
在这里插入图片描述

3、此时再查看一下分支情况

[root@git my_code]# git branch -a
在这里插入图片描述
可以看到我们想要的分支被显示出来了

4、切换分支

[root@git my_code]# git checkout master
[root@git my_code]# git branch --list
在这里插入图片描述
此时切换分支成功,问题解决

猜你喜欢

转载自blog.csdn.net/weixin_44178770/article/details/124830279