为什么我在git中看不到任何分支?

时间:2016-02-29 08:18:24

标签: git github

当我尝试git branch命令查看我的分支列表时,我看不到任何东西。快照:

enter image description here

正如您所看到的,命令git branchgit branch -v不会按预期显示分支列表。

Details :我一直在搞乱我的存储库一段时间了。我的repo的github网页说,分支hw3比主人提前17次提交。

是因为我在本地仓库中删除了分支hw'中的所有内容吗?

此外,当我尝试命令git checkout master时,我收到以下消息:

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

截至目前,我已删除了我机器上hw'分支中的所有内容,但Github网页仍显示所有这些文件。

另外,我在git init分支中输入命令hw3作为stackoverflow上另一个问题的建议。这对我有什么影响?

最初,我的hw3分支中有一堆文件,而我的主分支中只有一个README文件。我只想让事情恢复正常。

我该怎么办?谢谢!

1 个答案:

答案 0 :(得分:5)

没有任何参数的

git branch只打印出本地分支。

git branch 常见选项:

# print out local branches
git branch   

# print out remote branches
git branch -r

# print out local & remote branches
git branch -a

如何解决您的问题

首先使用远程仓库更新您的本地仓库

git fetch --all --prune

现在检查您需要的任何分支

git checkout master
相关问题