git 看不到远程分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12730344/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't see remote branch
提问by Crystal
I'm stil learning git and not sure how some basic things work. I created a local branch by doing:
我还在学习 git 并且不确定一些基本的东西是如何工作的。我通过执行以下操作创建了一个本地分支:
git branch AppStore
I can't remember exactly how I pushed this branch to github.com, but I can see MyBranch on the repository. When I do
我不记得我是如何将这个分支推送到 github.com 的,但我可以在存储库中看到 MyBranch。当我做
git branch -a
I see this:
我看到这个:
ARC
* AppStore
Refactoring
Release3
master
remotes/origin/AppStore
remotes/origin/HEAD -> origin/master
There are more remotes listed as well. So from my computer where I created the branch, I see the AppStore branch. However, none of my coworkers can. When we tried a
还列出了更多遥控器。所以从我创建分支的计算机上,我看到了 AppStore 分支。但是,我的同事都做不到。当我们尝试一个
git pull origin AppStore
It grabbed the changes. But when we tried
它抓住了变化。但是当我们尝试
git checkout AppStore
or
git checkout origin AppStore
We were not able to. What are we missing? Thanks!
我们没能做到。我们缺少什么?谢谢!
Edit:
编辑:
I did try this according to VonC's answer:
我确实根据 VonC 的回答尝试过这个:
git push --set-upstream origin AppStore
After putting in my credentials, I get:
输入我的凭据后,我得到:
Branch AppStore set up to track remote branch AppStore from origin.
Everything up-to-date
But my coworkers still cannot see the branch :-.
但是我的同事仍然看不到分支:-。
回答by VonC
You need to publish your branch on your upstream repo, while tracking it locally (making sure your local branch keep in synch with that new remote branch: see "What is a tracking branch")
你需要在你的上游仓库上发布你的分支,同时在本地跟踪它(确保你的本地分支与新的远程分支保持同步:参见“什么是跟踪分支”)
git push --set-upstream origin AppStore
As mentioned in the comments, the other developers need to fetch what has been pushed (included the new branch).
A git fetch origin is one way, but if you are unsure of the name of the remote repo, a git remote update
works just fine.
正如评论中提到的,其他开发人员需要获取已推送的内容(包括新分支)。
git fetch origin 是一种方式,但如果您不确定远程存储库的名称,agit remote update
可以正常工作。
That will update their remote branches, but won't create a local branch of the same name, as detailed in "Track all remote git branches as local branches".
这将更新他们的远程分支,但不会创建同名的本地分支,如“将所有远程 git 分支跟踪为本地分支”中所述。
回答by noMAD
When you do a git branch xyz
it creates a branch xyz
on your local machine. Generally you create a new branch off the master branch
so that it has the master's code
. After creating the branch xyz
, you make changes and then you have to git push origin xyz
for the branch to be visible on github
.
当您执行 a 时,git branch xyz
它会xyz
在您的本地机器上创建一个分支。通常,您创建一个新分支,master branch
以便它具有master's code
. 创建分支后xyz
,您进行更改,然后您必须更改git push origin xyz
分支才能在 上可见github
。
Doing git branch -a
will show your branches in your machine. Till you push
your branch you cannot find it on the remote repo.
这样做git branch -a
会在你的机器上显示你的分支。直到你push
的分支,你才能在远程仓库中找到它。