简体   繁体   English

GIT同一存储库在不同机器上的不同分支

[英]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.

相关问题 Mercurial / Git:同一存储库中不同分支的不同目录 - Mercurial/Git: Different directories for different branches in same repository git分支合理的不同机器的dotfile管理? - dotfile management for different machines with git branches reasonable? Git 和 Github 显示存储库中的不同分支 - Git and Github showing different branches in repository Git,不同的文件夹,相同的仓库,不同的分支 - Git, different folders, same repo, different branches 并行签出同一存储库的不同分支 - Parallel checkout of different branches of the same repository 如何为 Git 存储库的不同分支创建不同的 Conda 环境? - How to Create Different Conda Environments for Different Branches of a Git Repository? 如何从两个不同的来源在同一存储库上创建两个Git分支? - How do I create two Git branches on the same repository from two different sources? 如何结合单独的Git存储库来跟踪同一CVS存储库的不同分支? - How to combine separate Git repositories tracking different branches of the same CVS repository? 如何将相同的编辑推送到git中的不同分支? - How to push the same edit to different branches in git? 在不同分支中具有相同名称的Git子模块 - Git submodule with same name in different branches
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM