我不小心从我的回购分支的主分支创建了一个拉取请求.
在试图改变它时,我注意到所有这些变化都被推入了拉动请求中 - 因为你可以简单地做到这一点 Add more commits by pushing to the master branch on username/repo
我看到你可以编辑基本分支,但这显然不是我追求的.
AFAIK,您无法在创建请求请求后更改源分支。您必须创建一个新的。
供将来参考,已建立的最佳实践是在进行任何提交之前创建一个新分支。您不应该直接致力于掌握,尤其是在为团队项目做贡献时。
边注:
您可以通过推送到用户名/仓库的master分支来简单地添加更多提交
更正确地说,对PR目标分支的任何更改都自动包含在PR中。
由于您无法更改github中的源分支(您只能更改目标分支),因此您需要“就地”更新源分支。
这个答案包含三种方法。
在 Github 中你会看到:
githubuser 想要将“source-branch”中的 N 次提交合并到 master 中
由于您将更改“源分支”的历史记录,因此请确保没有其他人正在使用此分支!
如果您是唯一在该分支上开发的人,那么您可以git rebase -i
稍后使用 和git push --force-with-lease
。
这样你就可以重写这个分支的历史。
关于重写 git 历史记录的文档:https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
如果您喜欢从头开始。
git checkout master
# create a temporary branch
git checkout -b tmp-branch
... now modify the tmp-branch the way you want to. Commit, but don't push.
# rename tmp-branch to "source-branch"
git branch -f -m source-branch
# Be sure nobody is using "source-branch", since the history gets rewritten.
git push --force-with-lease
Run Code Online (Sandbox Code Playgroud)
想象一下,您的分支“源分支”意外地基于“发布”而不是“主分支”。但github目标分支是“master”。通过这种方式,您可以将更改更改为位于 master 之上:
git checkout source-pr
git rebase --onto master release
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4153 次 |
最近记录: |