man*_*off 22 git homebrew github pull-request
我对Git存储库中的两个文件进行了多处更改(具体来说,添加了两个brew公式).
我个别提交了更改:
git commit file1
git commit file2
Run Code Online (Sandbox Code Playgroud)
然后我向GitHub推了一下:
git push git@github.com:myname/homebrew.git
Run Code Online (Sandbox Code Playgroud)
我现在想向上游存储库发送两个pull请求,一个用于file1,一个用于file2.这可能吗?
Cas*_*bel 10
如果你在同一个提交中更改了两个文件,那么不,这是不可能的.推送和拉取在提交级别运行; 他们不会分开他们.
如果尚未共享更改,则可以将提交拆分为两个,为每个提交一个分支,然后为这些提交启动请求.
这是有很多方法可以做的事情之一,但是例如,你可以这样做:
# 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^
Run Code Online (Sandbox Code Playgroud)
这会让你有这样的历史:
- x (master) - A (first-branch)
\
- B (second-branch)
Run Code Online (Sandbox Code Playgroud)
其中,提交修改后的file1,并提交B修改后的file2.
一旦历史看起来像你喜欢它,你可以分别推动两个分支,并做你需要做的事情:
git push origin first-branch second-branch
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44034 次 |
| 最近记录: |