Lob*_*obo 7 git gerrit git-commit git-review
我使用git review命令发送了一个提交(名为"A commit")来审查(Gerrit).
现在,我进行了一次新的提交(名为"B commit"),我也希望将其发送给审查,但我不想重新发送"A commit".彼此之间没有依赖关系.
如何将评论发送给gerrit进行特定提交?
更新:
$ 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)
Run Code Online (Sandbox Code Playgroud)
提交" df68f1a "和" 4ce2d8d "是相关的,它们已在先前的git review命令中发送,但提交" 531bd84 "属于新分支(delete_role),因为这是一个新问题.
$ 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
Run Code Online (Sandbox Code Playgroud)
我想向Gerrit发送 " 531bd84 "提交,而不是其他提交.
在新分支中创建B提交.
在这个分支上,使用git review它只会将这个分支的内容推送到Gerrit.
这样,Gerrit不会认为你的提交B需要你的提交A,如果你愿意,你可以在提交A之前将你的提交B合并到工作分支
如果你的历史是这样的:
...-old(merged)-A(waiting for review)
Run Code Online (Sandbox Code Playgroud)
你想要做的是:
...-old(merged)-A(waiting for review) <-master branch
\B(new commit) <-new branch
Run Code Online (Sandbox Code Playgroud)
然后,如果你在分支B上并且使用git review它,那么除了提交B之外它不会推送任何东西
如果你遇到这种情况:
...-old(merged)-A(waiting for review)-B
Run Code Online (Sandbox Code Playgroud)
,你想要做什么来实现我们想要的配置是:
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)
Run Code Online (Sandbox Code Playgroud)
现在,您实现了所需的配置并推送B提交,您只需要:
git checkout Breview
git review
Run Code Online (Sandbox Code Playgroud)
它只会提交你的B提交
| 归档时间: |
|
| 查看次数: |
22427 次 |
| 最近记录: |