[英]I accidently branched off of a branch, now I want to undo this
How do I fix a branch so that it is synced with master? 如何修复分支,使其与主服务器同步? It'd almost be easier to delete the branch and then remake it, but I was wondering if there was a way to do this without it coming to that?
删除分支然后重新制作它几乎容易得多,但是我想知道是否有一种方法可以做到这一点呢?
When I made the branch, I branched off another branch instead of master. 当我创建分支时,我从另一个分支而不是master分支。
Rebase your changes onto master: 将您的更改重新基于master:
git rebase --onto master your-previous-source-branch
(when your current branch is active) (当您当前的分支处于活动状态时)
This will rewrite your branch like it was just branched off master and have all commits to it done after it. 这将重写您的分支,就像它刚从master分支出来一样,并在分支之后完成对它的所有提交。
Note that it will not be the same branch anymore and you'll have to do a forced push to remote, if branch is already there, be sure not to overwrite someone other's commits to it 请注意,它将不再是同一个分支,并且您必须强制执行到远程的操作,如果分支已经存在,请确保不要覆盖其他人对它的提交
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.