Git review: submit particular commit from multiple commits

7.8k Views Asked by At

I get the following on git review:

git review
You are about to submit multiple commits. This is expected if you are
submitting a commit that is dependent on one or more in-review
commits. Otherwise you should consider squashing your changes into one
commit before submitting.

The outstanding commits are:

2de3eef (HEAD -> AddingReleaseIndex) Adding index page for subrelease projects
d3dbc89 (Addingindex) Add index with submodules

Do you really want to submit the above commits?
Type 'yes' to confirm, other to cancel: no
Aborting.

I have many branches, each of which has a particular feature being implemented on it. I just want to send for review the commit on HEAD (2de3eef) and nothing else.

I found an article which says that I could use git cherry-pick to move a selected commit to another branch and send it for review from another branch. I dont want to send it for review through another branch, I want to send it via the same branch since its about a particular feature.

How do I get around this situation?

2

There are 2 best solutions below

2
Greg Hewgill On

One way you can do this is to use git rebase -i to reorder your commits so the one you want does not depend on any other commits that you don't want to submit.

0
Marcelo Ávila de Oliveira On

It seems you have something like this:

.. ---A     <= master
       \
        B   <= feature1
         \
          C <= feature2

This way (commit C based on commit B) if you push commit C to Gerrit you necessarily will push commit B too. You need to work the following way:

        B <= feature1
       /
.. ---A   <= master
       \
        C <= feature2

Commit C must be based on commit A. The feature1 and feature2 branches must be worked in parallel.