Is 'git review' a forced push in Gerrit?

1.9k Views Asked by At

I am bit confused about how git review works ?

I got the official documentation here fine manual but am still unable to understand how modifying a downloaded change and then comitting and pushing it using git commit --amend and git review works with simple push ?

I mean, isn't this same as rewriting history/making changese to pushed commit ?

Also there is git review -R, wondering when n why to use that ?

2

There are 2 best solutions below

0
viral_mutant On BEST ANSWER

I found my complete answer here. Comments from torek and Marcelo also helped

Basically, pushing to gerrit is not pushing to branch but a staging area(pending changes) which are references to the branches to which eventually each of the commits will be merged

These refs are also not exactly refs but some Gerrit magic to fool the client into belief of there existance

5
Marcelo Ávila de Oliveira On

If you:

  1. Download a OPEN change
  2. Make some changes
  3. Commit with --amend
  4. Push to Gerrit (refs/for/BRANCH)

You'll create a new PATCHSET for the previous change. The "git review" is just a tool to make the steps 1 and 4 more easy/automatic.

"git review -R" is used to skip the automatic "git rebase -i" step that is executed by git review before the push step. If you aren't sure what the "git rebase -i" does I think it's good don't use it.

I suggest you to read A Quick Introduction item on Gerrit documentation to learn more about Gerrit and to understand how it works