[英]How do I undo a merge , after I merged a branch into master branch
Guys I want to unmerge this localdevelopment branch from my master branch, also I pushed the master to origin/master, so now the commit history has also changed in the remote where in master branch I am also seeing the commits of this localdevelopment branch because I merged it, I only want the blue dots / commits from the above pic to be shown in the master branch, any fix for this.伙计们,我想从我的 master 分支中取消合并这个 localdevelopment 分支,我也将 master 推送到 origin/master,所以现在提交历史记录在远程 master 分支中也发生了变化,我也看到了这个 localdevelopment 分支的提交,因为我合并它,我只希望上面图片中的蓝点/提交显示在主分支中,对此进行任何修复。
git log git日志
copy commit from there and then从那里复制提交,然后
git reset --hard "your commit" git 重置 --hard “你的提交”
git push -f origin master git push -f origin master
try this:)尝试这个:)
Instead of copying commit, you can reset your branch with git switch
(Git 2.24+, Q3 2019):您可以使用
git switch
(Git 2.24+,2019 年第三季度)重置您的分支,而不是复制提交:
git switch -C master master~1
git push -f
From git switch -C
:从
git switch -C
:
-C <new-branch>
--force-create <new-branch>
Similar to
--create
except that if<new-branch>
already exists, it will be reset to<start-point>
.类似于
--create
,除了如果<new-branch>
已经存在,它将被重置为<start-point>
。
This is a convenient shortcut for:这是一个方便的快捷方式:
$ git branch -f <new-branch> $ git switch <new-branch>
By resetting master to one commit older ( ~1
), you affectively "forget" the merge commit.通过将 master 重置为一个较旧的提交(
~1
),您可以有效地“忘记”合并提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.