I have created a git repository on a linux server. 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. I have checked this on my machine as well where I’m also running ubuntu instance within VMWare, and it is really so. 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.
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:
origin/HEAD -> origin/master
origin/develop
origin/develop2
origin/master
on ubuntu git branch -r I get
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). 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
Note that
git branch -rwill only list remote branches that are stored within your local repository. So it does not necessarily mean that those branches exist like that on the remote repository itself. By default,git fetchwill however fetch all branches from the remote repository and add remote references into your local repository. So you will have all branches that exist on the remote locally as well.What
git fetchdoes not do however is clean up remote branches that were created but removed from the remote repository later. To do that, usegit fetch origin --prune. This will make Git update your remote branch list for the remote repository.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 -vto get a listing of your remote configuration and double-check if it is the same on both machines.