git review 不起作用?但是当我执行推送时,我能够看到我的更改。我究竟做错了什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19280472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:10:56  来源:igfitidea点击:

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

git

提问by NewUser07

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

我正在使用 git 和 gerrit。更改文件后,我执行以下操作:

  1. git status
  2. git add -> the modified files.
  3. git commit -m "the commit message"
  4. git review
  5. git push
  1. 状态
  2. git add -> 修改后的文件。
  3. git commit -m "提交信息"
  4. 混帐

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.

当我去 git review 时:我收到以下错误消息“在此存储库中找不到 '.gitreview' 文件。我们不知道您的 gerrit 在哪里。请手动创建一个名为 gerrit 的远程,然后重试。

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.

但是当我执行 git push 时,我可以在 remote.ie 上看到我的所有更改,即在那里进行了提交。但我不确定出了什么问题。

Any thoughts or leads appreciated.

任何想法或线索表示赞赏。

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

我在安装 git/gerrit 时已经创建了 gerrit。

回答by pmitchell

The gerrit command git reviewexpects 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:

gerrit 命令git review要求您设置一个名为gerrit. 如果您已经将存储库作为远程命名源(来自 a 的默认值git clone),您可以将其重命名为 git review 期望的名称:

git remote rename origin gerrit

git remote rename origin gerrit

回答by Johnny Z

git pushis 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

git push是一个 git 命令,与 gerrit 没有任何关系。您看到的错误仅与 gerrit 有关,它不会影响其他 git 命令,即git push

回答by Sven D?ring

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

在使用之前,git review您应该配置远程存储库名称。它默认为gerrit. 但是您可能希望将此默认值更改为,origin因为大多数存储库都被称为origin

Simply call:

只需调用:

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

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

--global如果它仅适用于单个项目,您可能需要删除。

This works for version 1.2.5 or newer.

这适用于 1.2.5 或更高版本。



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)

对于1.2.4版本或更早加gitreview配置文件:.config/git-review/git-review.conf
(Windows系统:%USERPROFILE%\.config\git-review\git-review.conf

With this content:

有了这个内容:

[gerrit] defaultremote = origin

[gerrit] defaultremote = origin

回答by Anil Reddy Yarragonda

Adding some more data to pmitchell's answer.

在 pmitchell 的回答中添加更多数据。

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

导航到您要使用的项目,并确保您可以连接到 Gerrit 服务器:

$ 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:

如果是这样,您可能将 Gerrit 服务器的“远程”称为 origin 或类似的东西。你可以这样检查:

$ git remote -v

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

您可能会得到类似这样的信息,其中 url 指向 Gerrit 项目:

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:

如果不是(即您有多个遥控器),您可能需要重命名相关遥控器或为 Gerrit 添加一个新遥控器:

$ git remote add gerrit [url]

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

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