简体   繁体   English

我的git分支在哪里?

[英]Where are my git branches?

I was working on my work computer the other day and set up a new branch in github. 前几天我在我的工作计算机上工作,并在github中建立了一个新的分支。 I made a local and remote branch. 我做了一个本地和远程分支。

Today I am working on my laptop at home and I don't see my branch that I made when I run "git branch". 今天我在家里的笔记本电脑上工作,当我运行“git branch”时,我看不到我的分支。

How do I get access to this branch? 我如何访问此分支?

assuming you have this branch in your local repository, you can use git checkout <branchname> to checkout a branch 假设您在本地存储库中有此分支,则可以使用git checkout <branchname>来签出分支

If this branch is on the github repository but not in your local repository, you may want to git remote update before git checkout <branchname> and git pull to fetch changes 如果此分支位于github存储库但不在本地存储库中,则可能需要在git checkout <branchname>之前进行git remote update ,并使用git pull来获取更改

What seems to have happened here, is that your local cache of the remote state is outdated. 这里似乎发生的是远程状态的本地缓存已过时。 Before you can access these new branches you will need to refresh your local copy of the repository's state. 在您可以访问这些新分支之前,您需要刷新存储库状态的本地副本。

You can do this with: 你可以这样做:

  1. git remote update (see the earlier answer by Michael Ira Krufky ) git remote update (参见Michael Ira Krufky 先前的回答
  2. git fetch [remotename]

Additionally when you run git pull this automatically includes a git fetch so that would also update your local copy 另外,当你运行git pull这会自动包含一个git fetch ,这样也会更新你的本地副本

尝试git branch -a来显示所有分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM