How to view a specific commit on Git

I sent a commit (named "A commit") to view (Gerrit) using the git review command.

Now I am making a new commit (with the name "B commit"), and I want to send it also for viewing, but I do not want to resend "A commit". There is no dependence on each other.

How to send gerrit feedback 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 " depend, and they were sent in the previous git review command, but committing " 531bd84 >" refers to the new branch (delete_role), because this is a new problem.

 $ 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 Gerrit only the message " 531bd84 " and not others.

+7
git git-commit gerrit git-review
source share
4 answers

Create commit B in the new branch.

Entering this branch, use git review , and it will only push the contents of this branch to Gerrit.

Thus, Gerrit will not assume that your commit B requires your commit A, and if you want, you can merge your commit B into a working branch before commit A

If your story is this:

 ...-old(merged)-A(waiting for review) 

What do you want to do:

 ...-old(merged)-A(waiting for review) <-master branch \B(new commit) <-new branch 

Then, if you are on branch B and using git review , it will not push anything except commit B

If you are in this situation:

 ...-old(merged)-A(waiting for review)-B 

what do you want to do to achieve your desired configuration:

 git log (Note the SHA1 of your B commit) git reset HEAD^^^ (you go back in detched state three commits before, before the two you don't want to send) git checkout -b Breview (you create a new branch there) git cherry-pick +the SHA1 you noted (you copy your B commit on your new branch) git checkout master (you return on your branch with the two commit) git reset HEAD^--hard (you delete the B commit from this branch where you don't need it) 

Now you have reached your desired configuration and pressed your B-commit, you just need to do:

 git checkout Breview git review 

and it will only send your B commit

+7
source share

Answers:

If you did not commit A before committing A make branch A, then pass your code to this branch and submit it for verification. Then go back to the wizard and create branch B, commit branch B and submit it for review. This way you guarantee no dependencies.

Ok, now let's say that you did everything in this host as follows:

 M----A----B 

This is your journal:

 commit b58fff12319d7ad1b1bc6ebcf4395d986a8ffac3 Author: Date: Fri Nov 8 09:48:23 2013 +0800 Change B commit 99f249cdf2352ace3ca9ee8bf7a8a732f27b31eb Author: Date: Fri Nov 8 09:47:56 2013 +0800 Change A commit f091b7a4cc5c0532973c5bd401d2171f6fb735ec Author: Date: Fri Nov 8 09:47:30 2013 +0800 Initial commit 

What we want is:

  A / / M \ \ B 

To create this creation, run the following commands:

 # Create two new branches from the point where the current Gerrit repo master is now git branch A f091b7a4cc5c0532973c5bd401d2171f6fb735ec git branch B f091b7a4cc5c0532973c5bd401d2171f6fb735ec git checkout A # Create a branch to hold change A git merge 99f249cdf2352ace3ca9ee8bf7a8a732f27b31eb git log commit 99f249cdf2352ace3ca9ee8bf7a8a732f27b31eb Author: Date: Fri Nov 8 09:47:56 2013 +0800 Change A commit f091b7a4cc5c0532973c5bd401d2171f6fb735ec Author: Date: Fri Nov 8 09:47:30 2013 +0800 Initial commit git checkout B git cherry-pick b58fff12319d7ad1b1bc6ebcf4395d986a8ffac3 git log # Note the new sha1 hash as this is change could not be fast forwarded commit d3aa1acc2b208115c7de78d5c9c4f6a906ece84a Author: Date: Fri Nov 8 09:48:23 2013 +0800 Change B commit f091b7a4cc5c0532973c5bd401d2171f6fb735ec Author: Date: Fri Nov 8 09:47:30 2013 +0800 Initial commit 

Now you have two branches, each of which has one change, pushing any of these changes to Gerrit will result in a simple push of one change.

Then you can clear the wizard by removing commits from there:

 git checkout master git reset --hard HEAD~2 

Especially for the update issue:

 git branch B 6751c7d git checkout B git cherry-pick 531bd84 

You have to create a branch from master 675c7d, then drag your commit 3 to a new branch, then you can delete your delete_role branch.

+4
source share

As I see, you have a branch that you work in, then you commit A, and the next commit B is also in the same branch. Therefore, logically they do not depend on each other, but for history, these changes depend. Thus, the first commit A needs to be reviewed and will be merged with the working branch before the second B can be merged.

Now, when you click on the links to the review, Gerrit already knows from the id change that you clicked to check. If you click on a branch for verification, only new commits will be sent, or they will be copied or updated.

In short. Gerrit knows what's new and what's already being seen.

+1
source share

After clicking commit "A", you can reset the local branch and start working on commit "B". Since each commit / change can be checked later from Gerrit after it has been clicked to view the branch. You can get a command from the Gerrit overview pane on each patch download panel. example:

 git fetch https://android.googlesource.com/kernel/tegra refs/changes/43/69243/2 && git checkout FETCH_HEAD 

After checking the change, you can change it and click again as a new set of patches. Therefore, you do not need to use local branches for each commit.

+1
source share

All Articles