NewUser07
NewUser07

Reputation: 107

git review doesn't work? but I am able to see my changes when I do a push. What am I doing wrong?

I am using git and gerrit. After changing my files, I do the following:

  1. git status
  2. git add -> the modified files.
  3. git commit -m "the commit message"
  4. git review
  5. git push

When I go git review: I get the following error message "No '.gitreview' file found in this repository. We don't know where your gerrit is. Please manually create a remote named gerrit and try again.

But when I do git push, I can see all my changes on the remote.i.e. the commit is made there. But I am not sure what's wrong.

Any thoughts or leads appreciated.

I already created gerrit when I was installing git/gerrit.

Upvotes: 9

Views: 24954

Answers (4)

Anil Reddy Yarragonda
Anil Reddy Yarragonda

Reputation: 767

Adding some more data to pmitchell's answer.

Navigate to the project you wish to use, and ensure you can connect to the Gerrit server:

$ cd <repo>
$ git review -s

You may get a warning like so:

No '.gitreview' file found in this repository.
We don't know where your gerrit is. Please manually create
a remote named gerrit and try again.

If so, you likely have your Gerrit review server’s “remote” called origin or something similar. You can check this like so:

$ git remote -v

You’ll likely get something like so, where the url points to a Gerrit project:

origin  <url> (fetch)
origin  <url> (push)

Assuming this is the case, just rename the remote:

$ git remote rename origin gerrit

If this isn’t (i.e. you have more than one remote), you may want to rename the relevant remote or add a new one for Gerrit:

$ git remote add gerrit [url]

Reference: https://that.guru/blog/how-to-use-git-review/

Upvotes: 2

Sven D&#246;ring
Sven D&#246;ring

Reputation: 4368

Before using git review you should configure the remote repository name. It's defaulted to gerrit. But you might want to change this default to origin as most repositories are called origin.

Simply call:

git config --global --add gitreview.remote origin

You might want to remove --global if it only applies for a single project.

This works for version 1.2.5 or newer.


For versions 1.2.4 or earlier add a gitreview config file: .config/git-review/git-review.conf
(Windows: %USERPROFILE%\.config\git-review\git-review.conf)

With this content:

[gerrit] defaultremote = origin

Upvotes: 6

pmitchell
pmitchell

Reputation: 404

The gerrit command git review expects that you have a remote repository set up named gerrit. If you already have your repository as a remote named origin (the default from a git clone), you can rename it to what git review expects with this:

git remote rename origin gerrit

Upvotes: 24

Johnny Z
Johnny Z

Reputation: 15449

git push is a git command, and doesn't have anything to do with gerrit. The error you are seeing has to do with gerrit only, and it doesn't effect the other git commands, i.e. git push

Upvotes: 1

Related Questions