I sent a commit (named "A commit") to review (Gerrit) using git review
command.
Now, I make a new commit (named "B commit") and I want to send it to review as well, but I don't want to re-send the "A commit". There is no dependencies each other.
How to send a review to gerrit for a specific commit?.
UPDATE:
$ git add --all
$ git status
# On branch delete_role
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: path/to/file.ext
$ git status
# On branch delete_role
nothing to commit (working directory clean)
$ git branch
*delete_role
master
$ git log --graph --decorate --oneline -n13
* 531bd84 (HEAD, delete_role) commit 3
* df68f1a (master) commit 2
* 4ce2d8d commit 1
* 6751c7d (origin/master, origin/HEAD, gerrit/master)
Commit "df68f1a" and "4ce2d8d" are dependant and they have been sent in a previous git review
command, but commit "531bd84" belongs to a new branch (delete_role) because is a new issue.
$ git review
You have more than one commit that you are about to submit.
The outstanding commits are:
531bd84 (HEAD, delete_role) commit 3
df68f1a (master) commit 2
4ce2d8d commit 1
I want to send to Gerrit only the "531bd84" commit, not the other ones.
Create the B commit in a new branch.
While being on this branch, use
git review
and it will only push the content of this branch to Gerrit.This way, Gerrit won't consider that your commit B needs your commit A and if you want, you can merge your commit B to the working branch before commit A
If your history is like this:
what you want to do is:
Then, if you're on branch B, and use
git review
, it won't push anything else than commit BIf you're in this situation:
, what you want to do to achieve the configuration we want is:
Now, you achieved the wanted configuration and to push your B commit, you just need to do:
and it will only submit your B commit
The way I see it you have branch where you work, then you have commit A and next commit B is also in the same branch. So logically they don't depend on each other but for history those changes are dependent. So first commit A will need review and be merged to working branch before second B could be merged in.
Now when you push references to review, Gerrit already knows by change id's what you have pushed for review. If you push branch to review only new commits will be sent, or commits that were updated or rebased.
Long story short. Gerrit knows what is new and what is already in review.
Branches are the answer:
If you have not made commit A then before making commit A make branch A, then commit your code to that branch and submit it for review Then, go back to the master and create branch B, commit to branch B and submit for review. This way you ensure that there are no dependencies.
Ok, now lets say that you have committed everything in the master like this:
This is your log:
What we want is this:
To get this create perform the following commands:
Now you have two branches that hold one change each, pushing either of these changes to Gerrit will result in just one change being pushed.
Then you might want to clean up you master by remove the commits from there:
Specially for the update question:
You should create the branch from the gerrit master 675c7d, then cherry-pick your commit 3 into the new branch, then you can delete your old branch delete_role
After pushing commit 'A' you can reset the local branch and start working on commit 'B'. Since every commit/change can be checked out from Gerrit later once it was pushed to review branch. you can get the command from Gerrit review board at each patchset download panel. an example:
After checking out a change it can be amend and pushed again as a new patchset. So you dont have to use local branches for each commit.