介绍一下每次pull request时指定某个commit的操作。

获取于源仓库的联系

首先需要创建远程仓库,指向源仓库

git remote add upstream [email protected]:userName/test.git

并且从该仓库拉取代码

git fetch upstream

在本地创建专用的分支

进入到这个仓库,并且新建一个分支专门来进行pull request

#切换分支
git checkout upstream/master

#新建分支
git checkout -b <new-branch-name>

上面两步合在一起就是

git checkout -b <new-branch-name> upstream/master

使用cherry-pick

然后用cherry-pick选择commit,后面的一串就是你需要pull requestcommit id

git cherry-pick <commit-id>

如果当前这个commit和源仓库有冲突可以撤销commit进行修改后再提交

git reset --soft HEAD^

而如果只是想要改一下commit的信息只要运行下面这行代码就行了

git commit --amend

提交到远程仓库并pull request

一切准备妥当之后就可以把这个专用的分支提交到远程仓库了

git push origin <new-branch-name>

然后去到github.com中的的自己的仓库中去,找到branch

image.webp

然后找到我们之前创建的分支,然后把它pull request即可

image.webp