Git: no new remote branch visible

A colleague pushed a new remote branch to the beginning of / dev / homepage, and I can’t see it when I run:

$ git branch -r 

I still see previous deleted branches.

I assume this is because my local remote links did not match the last when I started git, nothing happened, since git pull only pulls the current working branch correctly? Unlike git push, which pushes all branches that have changes in the corresponding remote branch?

+42
git
06 Oct
source share
5 answers

First, double check that the branch has been removed remotely using the git ls-remote origin . If a new branch appears on the output, try and give the git fetch command: it should load the links to the branch from the remote repository.

If your remote branch is still not displayed, double-check (in the output of ls-remote ) what the branch name is on the remote control and, in particular, if it starts with refs/heads/ . This is because the default value for remote.<name>.fetch is:

 +refs/heads/*:refs/remotes/origin/* 

so only remote links whose name begins with refs/heads/ will be displayed locally as remote tracking links in the refs/remotes/origin/ section (i.e. they will become remote tracking branches)

+69
Oct. 06
source share

Performing a remote upgrade git will also update the list of branches available from the remote repository.

If you use TortoiseGit starting from version 1.8.3.0, you can do "Git β†’ Sync", and the "Remote update" button will appear in the lower left corner of the window that appears. Click on it. Then you can do "Git β†’ Switch / Checkout" and in the drop-down list of branches you can select a new remote branch.

+17
Jun 26 '13 at 20:05
source share

Check if .git/config contains

 [remote "origin"] url = … fetch = +refs/heads/master:refs/remotes/origin/master 

If so, change it to say

 [remote "origin"] url = … fetch = +refs/heads/*:refs/remotes/origin/* 

Then you can use it:

 $ git fetch remote: Counting objects: … remote: Compressing objects: .. Unpacking objects: … remote: … From … * [new branch] branchname -> origin/branchname $ git checkout branchname Branch branchname set up to track remote branch branchname from origin. Switched to a new branch 'branchname' 
+6
Sep 06 '17 at 17:26
source share

I finally managed to add the name of the remote repository to the git fetch command, for example:

 git fetch core 

Now you can see them all like this:

 git branch --all 
+1
May 05 '17 at 3:55 a.m.
source share

This sounds trivial, but my problem was that I was not in the right project. Make sure you are in the project you are expecting; otherwise, you will not be able to output the correct branches.

0
Oct 23 '17 at 22:21
source share



All Articles