简体   繁体   English

将分支合并到主分支后,如何撤消合并

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

相关问题 撤消git merge origin / master-Bitbucket-将错误的分支合并到本地 - Undo git merge origin/master - Bitbucket - Merged wrong branch into local 如何撤消合并或将我的master分支向前移动? - How do undo a merge or move my master branch forward? 如何从 master 创建发布分支,不包括已经在 master 中合并的特定分支 - How do I create release branch from master, excluding particular branch which is already merge in master Git:如何将本地分支合并到远程主分支 - Git: How can I merge local branch into remote master branch 使用git扩展如何在不更改功能分支的情况下将我的功能分支合并到主分支中? - Using git extension how do I merge my feature branch into the master branch without changing my feature branch? Git合并-如果合并一个旧分支,旧问题会合并到master中吗? - Git merge- will old problems be merged into master if I merge an old branch? 如何停止与开发分支合并的分支与主分支合并? - How to stop a branch merged with develop branch to be merged with master branch? 如何更改上一次提交中合并到的分支? - How do I change the branch I merged into in my previous commit? 如何将本地分支合并到TFS中 - How do I merge a local branch into TFS 当远程服务器上不存在本地分支且未与源/主服务器合并时,如何在远程Git服务器上测试本地Git分支? - How do I test a local Git branch on the remote Git server, when the local branch does not exist on the remote server, no merge with the origin/master?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM