Git review: Make the remote not be named Gerrit

时间:2016-08-31 17:17:10

标签: git gerrit git-review

My workplace started using Gerrit and git review, which I've never used before. My remote is called acme, but it seems like git review wants the remote to be called gerrit. If possible I'd like to avoid changing the name of my remote. I'd like my remote to still be called acme and I want git review to work with that remote as if it was called gerrit. Is that possible?

1 个答案:

答案 0 :(得分:1)

You don't necessarily want git review to be using the same remote you use for your regular work. The OpenStack project makes heavy use of Gerrit, and a typical checked out project, after configuring Gerrit, might look like:

$ git remote -v
gerrit  ssh://lars@review.openstack.org:29418/openstack/nova.git (fetch)
gerrit  ssh://lars@review.openstack.org:29418/openstack/nova.git (push)
larsks  git@github.com:larsks/nova.git (fetch)
larsks  git@github.com:larsks/nova.git (push)
origin  git://github.com/openstack/nova.git (fetch)
origin  git://github.com/openstack/nova.git (push)

In this example, origin is a read-only remote from which I can pull changes, and gerrit is the remote used by git-review to submit reviews. There's a remote named larsks that maps to my personal GitHub repository; I use this one to stage changes before submitting them to gerrit (this makes sure that if my laptop blows up the changes are preserved, and it also makes it convenient to move between a couple of different workstations and use this remote for syncing back and forth).

You can of course also just create multiple remotes that have different names but point to the same URL, if that's ultimately how you want things to work.

(If you're curious, you can read more about the Openstack gerrit workflow)