[Insight-developers] Pushing to the same Gerrit patch number

Marcus D. Hanwell marcus.hanwell at kitware.com
Fri Dec 17 13:25:50 EST 2010


On Fri, Dec 17, 2010 at 12:58 PM, David Doria <daviddoria at gmail.com> wrote:
>> That results in 2 because it's 2 git commits.
>
>
> On the GitVTKCheatSheet.pdf, it says "Respond to review: 'git rebase -i
> HEAD~3', 'git gerrit-push' ". I guess this is the part I don't follow. Why
> do you have to rebase here? Why can't you just commit the change like normal
> (i.e. instead of the rebase+push why isn't it just a commit+push?) ? Also,
> don't you have to rebase+commit+push (i.e. the rebase kind of "undoes"
> things, and you need to put them back together before pushing)?
> How about another git alias so you can do:
> 1) // change files in response to review
> 2) git gerrit-PushNextPatch
> that does whatever it needs to do to do this without all of the headache?
> David

Because this is the point at which you need to think about what must
be done. If you have a topic branch with three commits on it, and you
need to edit the second commit, then the final commit will also change
(as its parent has changed). In this case, go read the Git Pro book
(or your source of choice) on interactive rebasing.

If it is a simple topic, with just one commit, or you only need to
change the final commit, then git commit --amend will do, but you must
add the changed file to the index before amending. What if you have
some other locally modified files that should not be added to the
amended commit?

There is only so much we should do with aliases, beyond that point you
need to learn how to use these tools. We have tried to point people to
those sources. The plans we have for adding topic level review to
Gerrit should make things like this simpler. I think it is the right
thing to do for us to direct people to Git resources, just like we do
for C++ resources - we are not here to teach Git or C++.

You should check out something like the Git Pro book on editing
commits, amending a commit is the simplest case, interactive rebasing
is often required when you have a multi-commit topic branch.

Marcus


More information about the Insight-developers mailing list