3

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?

Jmills
  • 2,414
  • 2
  • 19
  • 22
FlyingAura
  • 1,541
  • 5
  • 26
  • 41
  • What about the d3dbc89 commit? Is it yours? Why 2de3eef commit is based on it? Why you don't want to push it? – Marcelo Ávila de Oliveira Jan 04 '17 at 11:27
  • The commit is mine but on another branch. Each branch is a feature branch and only the relevant features should be going on the branch. d3dbc89 is a feature relevant to AddingReleaseIndex, d3dbc89 is not relevant to AddingReleaseIndex – FlyingAura Jan 04 '17 at 17:26

2 Answers2

3

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.

2

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.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 1
    Can you please elaborate? – FlyingAura Jan 04 '17 at 07:24
  • If I own the commits and just want to submit them as separate patches (this will not commit patches with no changes) I would put each review into it's own branch and git checkout into each one for the following operations. Then with git rebase -i master n+1 then rebase -i n+1 n+2 and so on, until you reach the branch with the commit you want to submit for review. For each rebase -i n n+1 you would add pick from top to bottom in the order they need to be rebased, where the top pick should be the master branch and the last commitId is that branch's commit for review. – Trevor McCasland Oct 30 '17 at 15:50