1

Through Gerrit Web UI I created a branch from one of old commits in the commit chain

A previous version of code repository exists locally.

I make a git pull command to update my local repo.

I try to run git branch -a and this newly created branch does not show up.

However, if I clone this repo elsewhere all branches show up as desired.

Can anyone please throw some light on this?

Update:

I tried running git ls-remote as described in this question. This displays the newly created head. However, git branch -a does not show updated status of the repository.

Community
  • 1
  • 1
Vikram
  • 4,162
  • 8
  • 43
  • 65

4 Answers4

2

git pull <remote> or git pull command will only update your local repo but when you run git branch command, the branch created from Gerrit will not show up. You will need to run the following to command:

$git check -b branch_name --track origin/branch_name

where branch_name is the branch name created in Gerrit.

Szymon
  • 42,577
  • 16
  • 96
  • 114
developer
  • 21
  • 3
0

Seems like a bug. This is indeed the case but you can actually do a git checkout new-branch and after this the branch will show up when you do git branch -a

This seems a bit strange as you can not see the branch but you can checkout the branch. I assume you also saw the [new branch] test-branch -> origin->test-branch when you did git pull

uncletall
  • 6,609
  • 1
  • 27
  • 52
  • thanks for your answer...you are right I did not see that message `[new branch]...` on `git pull` – Vikram Jul 18 '13 at 13:12
0

I still do not understand the reason why this would happen. However one way is to clone the repo elsewhere...this fixed my problem.

If for some reason clone is not an option for you, delete the remote refs and add it back again like this:

git remote -v

#will display list of all...

<remote name> <remote url/ or ssh alias(if configured)>
<remote name> <remote url/ or ssh alias(if configured)>
.....

git remote rm <remote name>

# add the same remote again
git remote add <remote name> <remote url or ssh alias(if already configured)>

# now pull 
git pull <remote name>
Vikram
  • 4,162
  • 8
  • 43
  • 65
0

Try using this command before others, and the branch will show up:

git fetch origin <branch_name>
Maryam Homayouni
  • 905
  • 9
  • 16