I have two directories on my local machine pointing to the same remote git repository.
When I issue the command git branch -r
in one of the directories I get a longer list of remote branches then in the other directory. How is that possible ?
It seems that some of the remote branches are 'hidden' in one directory and are visible in the other.
To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual git checkout and git log commands. If you approve the changes a remote branch contains, you can merge it into a local branch with a normal git merge .
If you have a single remote repository, then you can omit all arguments. just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.
I had the same issue, couldn't get the remote branches on one of my local directories. git branch -r
would show less branches and also not the top-most change, while on the other directory everything was refreshing nicely.
To fix this, I did git config -l
on both directories and found out that I was missing the remote.origin.fetch
setting. Running the following line fixed my problem:
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git fetch
From github.com:username/test2
2bd5e5e..2619d39 master -> origin/master
* [new branch] remotebr2 -> origin/remotebr2
* [new branch] remotebranch -> origin/remotebranch
I think you should fetch and prune:
prune
Deletes all stale tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>".
With --dry-run option, report what branches will be pruned, but do not actually prune them.
With this commandlines:
git fetch
git remote prune origin
Are both repositories up-to-date? Try running git fetch
and see if that fixes it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With