我对Git存储库中的两个文件进行了多处更改(具体来说,添加了两个brew公式).
我个别提交了更改:
git commit file1 git commit file2
然后我向GitHub推了一下:
git push git@github.com:myname/homebrew.git
我现在想向上游存储库发送两个pull请求,一个用于file1,一个用于file2.这可能吗?
将每个文件放在自己的分支上.您可以为每个分支生成一个拉取请求,该请求可以执行您想要的操作.
如果你在同一个提交中更改了两个文件,那么不,这是不可能的.推送和拉取在提交级别运行; 他们不会分开他们.
如果尚未共享更改,则可以将提交拆分为两个,为每个提交一个分支,然后为这些提交启动请求.
这是有很多方法可以做的事情之一,但是例如,你可以这样做:
# make sure the commit in question is the most recent # make branch to point to the previous commit, leaving the changes in your work tree git reset HEAD^ # commit the changes to the first file git add file1 git commit # make a branch for the first commit git branch first-branch HEAD^ # commit the changes to the second file git add file2 git commit # create and check out a branch for this commit git checkout -b second-branch # rebase the branch back, so that it doesn't include the first commit git rebase --onto HEAD^^ HEAD^ second-branch # point your master branch somewhere that makes sense - maybe before either branch git checkout master git reset --hard first-branch^
这会让你有这样的历史:
- x (master) - A (first-branch) \ - B (second-branch)
其中,提交修改后的file1,并提交B修改后的file2.
一旦历史看起来像你喜欢它,你可以分别推动两个分支,并做你需要做的事情:
git push origin first-branch second-branch