简体   繁体   English

我不小心从一个分支分支了,现在我想撤消这个

[英]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.

相关问题 我分支了一个未合并的功能分支,但该未合并的分支现已合并 - I branched off an unmerged feature branch, but that unmerged branch has now been merged Git:我分支出的Change分支 - Git: Change branch I have branched off of 我没有从分支机构分支,而是从分支机构分支 - I didnt branch off of master, instead branched off of a branch 意外地分支了错误的分支,当我想合并到主服务器时,我必须合并两个分支 - Accidentally branched off of the wrong branch, and when I want to merge into the master I have to merge both branches <git>我已经分支了一个分支并想要推送我的更改。 我是将更改推送到原始分支还是合并两个分支?</git> - <GIT> I have branched off a branch and want to push my changes. Do I push changes to the original branch or merge the two branches? 如何打印分支从主分支分支出来的子树? - How do I print the subtree where branch branched off master? 我分支了错误的分支,如何将更改移动到正确的分支? - I branched off the wrong branch, how do I move my changes to correct branch? 如何更改我分支的git分支? - How do I change the git branch from which I branched? Git:分支但父分支已更改 - Git: branched off but parent branch has changed 如何更改分支的根分支 - How to change the root branch that was branched off of
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM