在GitHub上执行请求时避免不需要的合并提交和其他提交 [英] Avoid unwanted merge commits and other commits when doing pull request on GitHub
问题描述
让远程上游为上游
,并且我的远程存储库为来源
。
我的本地 master
分支设置为跟踪远程 master
分支。
然后我在本地 master
中添加了一些东西,并且我偶尔会与上游进行合并。
直到今天,当我想发出pull请求时,我发现问题:
pull request包含那些合并提交和那些不需要的提交我以前没有在意。然而,我想要的只是提交我所做的最后一次提交,应该将其作为单个提交进行提交。
我该怎么做才能解决这个问题?
而不是合并你想重新分配。您可以手动执行此操作,或者在执行操作时自动执行此操作。
git pull --rebase upstream master
git push - 强制原始大师
一旦开始合并虽然这很难完成,需要将分支重置回合并提交之前。
I forked a project on Github.
Let the remote upstream be upstream
and my remote repository be origin
.
My local master
branch is set to track the remote master
branch.
Then I added some stuff in local master
, and I merged with the upstream every now and then.
Not until today when I want to issue a pull request did I find the problem: the pull request consists those merge commits, and those unwanted commits that I did previously without care. However what I want is just to submit the last commit I did, which should be pulled as a single commit. What can I do to rescue this?
Instead of merging you want to rebase. You can do this manually, or automatically when pulling.
git pull --rebase upstream master
git push --force origin master
Once you've started doing merges though this will get hard to do, you'll need to reset the branch back to before you did a merge commit.
这篇关于在GitHub上执行请求时避免不需要的合并提交和其他提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!