[英]GIT: How can I do a pull request when I've already commited to my master branch?
My remote repo's master branch looks like this (each one is a commit): 我的远程仓库的master分支如下所示(每个分支都是一个提交):
A - B - C - D - E - F - G A-B-C-D-E-F-G
I would like to get a code review that diffs C and G (C's changes from B should not be displayed). 我想获得一个对C和G进行比较的代码审查(不应显示C对B的更改)。 How do I do this?
我该怎么做呢?
Do I have to 我一定要吗
- create tmpBranch at master (pointing to G)
- branch from C (newBranch)
- move my master branch to newBranch
- delete newBranch
- push these branch changes to repo
- submit pull request
or is there an easier approach? 还是有更简单的方法? If no, what are the commands that will do the above?
如果不是,执行上述命令的命令是什么?
Branches are just labels to the HEAD commit. 分支只是HEAD提交的标签。 So, you essentially just need to change the labels.
因此,您基本上只需要更改标签。
It's not a good idea to change public history, unless your repo is your own. 除非您的回购单是您自己的,否则更改公共历史记录不是一个好主意。 So, I'm assuming nobody uses your
master
branch. 因此,我假设没有人使用您的
master
分支。
$ git checkout G
$ git checkout -b review-this # Create the branch to be reviewed.
$ git checkout master
$ git reset --hard C # Reset the master to commit C
$ git push -f <remote-name> master # Force push the master branch
$ git push <remote-name> review-this # Push the new branch
# Submit the pull request
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.