GIT:当我';你已经向我的主分支机构提交了吗?

GIT:当我';你已经向我的主分支机构提交了吗?,git,github,branch,git-branch,git-pull,Git,Github,Branch,Git Branch,Git Pull,我的远程回购的主分支如下所示(每个分支都是提交): A-B-C-D-E-F-G 我希望得到一个区分C和G的代码评审(不应显示C对B的更改)。我该怎么做 我一定要吗 - 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 - s

我的远程回购的主分支如下所示(每个分支都是提交):

A-B-C-D-E-F-G

我希望得到一个区分C和G的代码评审(不应显示C对B的更改)。我该怎么做

我一定要吗

- 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

还是有更简单的方法?如果否,将执行上述操作的命令是什么

分支只是头部提交的标签。因此,您基本上只需要更改标签

改变公共历史不是一个好主意,除非你的回购协议是你自己的。因此,我假设没有人使用您的
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
$git签出G
$git checkout-b查看此#创建要查看的分支。
$git签出主机
$git reset--硬C#将主机重置为提交C
$git push-f master#强制推动主分支
$git push查看此#推送新分支
#提交拉取请求

谢谢你,在我致力于掌握一个从开源项目克隆而来的项目之后,这对我很有帮助。后来我想向项目提交一个pull请求,所以我将我的旧master更改为
myprojectmaster
,并进行了硬重置,并拉取了开源的master分支。然后我又能在开源项目上进行合作了。谢谢