如何检查Git上的特定提交 [英] How to review a specific commit on Git
问题描述
我使用 git review
命令发送了一个提交(名为A commit)来检查(Gerrit)。
<现在,我做了一个新的提交(名为B commit),并且我想将它发送给复审,但我不想重新发送A提交。没有彼此之间的依赖关系。
如何将评论发送给gerrit以进行特定的提交?
UPDATE :
$ git add --all
$ git status
#分支delete_role
#要提交的更改:
#(使用git reset HEAD< file> ...以取消存储)
#
#modified:path / to / file.ext
$ git status
#分支上delete_role
没有提交(工作目录清理)
$ git分支
* delete_role
主人
$ 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 和 4ce2d8d 是依赖的,它们已经在之前的 git review
命令中发送,但是c ommit 531bd84 属于新分支(delete_role),因为是新问题。
您有多个提交,您即将提交。
未完成的提交是:
531bd84(HEAD,delete_role)commit 3
df68f1a(master)commit 2
4ce2d8d commit 1
我只希望向Gerrit发送 531bd84 提交,而不是其他的。
在一个新的分支中创建B提交。
<在这个分支上,使用 git review
,它只会将这个分支的内容推送到Gerrit。
<通过这种方式,Gerrit不会认为你的提交B需要你的提交A,如果你愿意,你可以在提交之前将你的提交B合并到工作分支中A
如果你的历史是这样的:
...-旧(合并)-A(等待审核)
您要做的是:
...- old(合并)-A(等待审核)< -master branch
\ B(新提交)< -new branch
然后,如果你在分支B上,并使用 git review
,它将不会推送任何其他内容而不是提交B
如果您处于这种情况:
...-旧(合并)-A(等待审核)-B
<你想要做什么来实现我们想要的配置:
$ g $ log(注意你的B提交的SHA1 )
git reset HEAD ^^^(你回到之前的三级提交状态,在你不想发送的两个之前提交)
git checkout -b Breview(你在那里创建一个新的分支)
git cherry-pick +你注意到的SHA1(你在你的新分支上复制你的B提交)
git checkout master(你用这两个提交返回你的分支)
git reset HEAD ^ --hard(你从这个分支中删除了你不需要它的B提交)
现在,你实现了想要的配置,并推动你的B提交,你只需要做:
gi t checkout Breview
git review
只会提交您的B提交
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:
...-old(merged)-A(waiting for review)
what you want to do is:
...-old(merged)-A(waiting for review) <-master branch
\B(new commit) <-new branch
Then, if you're on branch B, and use git review
, it won't push anything else than commit B
If you're in this situation:
...-old(merged)-A(waiting for review)-B
, what you want to do to achieve the configuration we want is:
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 achieved the wanted configuration and to push your B commit, you just need to do:
git checkout Breview
git review
and it will only submit your B commit
这篇关于如何检查Git上的特定提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!