[英]GIT same repository different branches on different machines
I have created a git repository on a linux server. 我已经在Linux服务器上创建了一个git存储库。 For a longer part I was working alone and everything was working fine.
在很长一段时间里,我一个人工作,一切都很好。 When a friend joined in, he complained that he can only see master branch.
当一个朋友加入时,他抱怨说他只能看到master分支。 I have checked this on my machine as well where I'm also running ubuntu instance within VMWare, and it is really so.
我已经在我的机器上检查了这个,我也在VMWare上运行ubuntu实例,的确如此。 To confuse me even more, I was able to push a new branch from ubuntu machine, that is visible only from inside ubuntu client, but not visible on the client on windows.
更让我困惑的是,我能够从ubuntu机器上推送一个新分支,该分支仅在ubuntu客户端内部可见,而在Windows客户端上则不可见。
So the problem I'm facing is that from the two (in my case logically) separate machines, but against the same repository I'm seeing different branches 所以我面临的问题是,从两台(在我的逻辑上来说)分离的机器中,但是在同一个存储库中,我看到了不同的分支
I originally pushed branches using Git bash on windows, and if I there I run git branch -r I get: 我最初是在Windows上使用Git bash推送分支的,如果我在那里运行git branch -r,我会得到:
origin/HEAD -> origin/master
origin/develop
origin/develop2
origin/master
on ubuntu git branch -r I get 在ubuntu git branch -r我得到
origin/HEAD -> origin/master
origin/develop3
origin/master
I can do git fetch as much as I like, simply things act like that they are working against a separate repo (aside for the shared master branch). 我可以根据自己的喜好进行git fetch提取 ,只是事情的行为就像它们针对一个单独的仓库(共享主分支除外)一起工作。 It could be that I have miss-configured the git server in some way, or maybe an issue with keys, not sure, need suggestions, thanks
可能是我以某种方式未正确配置git服务器,或者可能是密钥问题,不确定,需要建议,谢谢
Note that git branch -r
will only list remote branches that are stored within your local repository. 请注意,
git branch -r
将仅列出存储在本地存储库中的远程分支。 So it does not necessarily mean that those branches exist like that on the remote repository itself. 因此,这不一定意味着这些分支像远程存储库本身那样存在。 By default,
git fetch
will however fetch all branches from the remote repository and add remote references into your local repository. 默认情况下,
git fetch
将从远程存储库中获取所有分支,并将远程引用添加到本地存储库中。 So you will have all branches that exist on the remote locally as well. 因此,您将拥有远程存在于本地的所有分支。
What git fetch
does not do however is clean up remote branches that were created but removed from the remote repository later. 但是,
git fetch
不会执行的工作是清理已创建但稍后从远程存储库中删除的远程分支。 To do that, use git fetch origin --prune
. 为此,请使用
git fetch origin --prune
。 This will make Git update your remote branch list for the remote repository. 这将使Git更新您的远程存储库的远程分支列表。
So if the branches got removed later, you will notice it that way. 因此,如果以后删除了分支,您将以这种方式注意到它。 If this will not get the remote branch list in sync, then it is likely, that your remote repositories are actually not the same.
如果这不会使远程分支列表同步,则可能是您的远程存储库实际上并不相同。 You can use
git remote -v
to get a listing of your remote configuration and double-check if it is the same on both machines. 您可以使用
git remote -v
获取您的远程配置列表,并仔细检查两台计算机上的配置是否相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.