github在pr时只提交指定commit的方法

1. 同步上游分支:

GitHub Pull Request入门 - 知乎

首先:

git remote add upstream XXX.git

git fetch upstream

然后就可以从upstream里选取要同步的分支merge到本地了。

2. 挑选commit进行pull request:

github在pull request时只提交指定commit的方法_Jonariguez 吾本优秀-CSDN博客_git pull 指定commit

假设本地的某分支上进行了很多改动,只希望对其中的一些改动对原项目提出pr。

按照1中步骤操作后,从原项目(假设从master上)向本地拉取一个新分支:

git checkout -b new_branch upstream/master

在这个new_branch分支上cherry-pick本地其他分支上希望pr的commit:

git cherry-pick commit1 commit2 commit3 ...

然后push到远程origin:

git push origin new_branch

最后在github上对new_branch向原项目提出pr。


版权声明:本文为hanmoge原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。