1

When I clone a project I normally get duplicated remote branches, one branch is remotes/origin/xxx and the other is remotes/gerrit/xxx . What is the difference? When I do git review, which one I am using to push my commit?

For example:

  master
* testing
  remotes/gerrit/master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
M. Buil
  • 529
  • 1
  • 4
  • 22
  • 1
    Is this the output of your "git branch -a" command? What is the output for "git remote -v"? – Marcelo Ávila de Oliveira Mar 09 '17 at 18:40
  • when you're doing a review, you're probably using gerrit. I doubt you have push rights to origin. @MarceloÁviladeOliveira 's question will tidy up whether or not you have push rights to which remote repo. – g19fanatic Mar 09 '17 at 18:46
  • That's the output of `git branch --all`. Yes, I am using gerrit to do the review. Does that mean that the /remotes/gerrit branches are normal when using gerrit? – M. Buil Mar 09 '17 at 18:49
  • 1
    Please, add the "git remote -v" command output. – Marcelo Ávila de Oliveira Mar 09 '17 at 18:58
  • I am pretty sure that when you clone with git, it creates just the single remote "remotes/origin/master". Then when you invoke "git-review" for the first time, that tool adds the remote "remotes/gerrit/master". – chrisinmtown Jan 02 '20 at 16:26

1 Answers1

0

Git-review will automatically create this remote based on the settings in your .gitreview file when it is first used. This is explained in the Installation and Configuration of git-review. https://docs.openstack.org/infra/git-review/installation.html

Ilion
  • 6,772
  • 3
  • 24
  • 47
  • I believe it does. See here http://stackoverflow.com/questions/10461214/why-is-git-push-gerrit-headrefs-for-master-used-instead-of-git-push-origin-mast – Ilion Mar 09 '17 at 20:16
  • No, it does not. And it cannot, as git remotes are a client-side setting. Configuring an optional `gerrit` remote is just a convenience thing some people to [simplify pushing for a review](http://stackoverflow.com/a/29585536/1127485). – sschuberth Mar 09 '17 at 20:22
  • No... this is not related to the remote name (gerrit), this is related to the use of the "refs/for" prefix in branch name. The remote name doesn't matter. Gerrir doesn't create any "gerrit" remote, it uses the default "origin" name. – Marcelo Ávila de Oliveira Mar 09 '17 at 20:31
  • You guys are right. It'd gotten confused between the remote and the refs/for. I've edited my post with what I think is the likely solution. – Ilion Mar 09 '17 at 21:16
  • Do you experts recommend adding a "defaultremote=" entry to the .gitreview file to direct git-review, and avoid having both remotes/origin/master and remotes/gerrit/master? – chrisinmtown Jan 02 '20 at 16:22