简体   繁体   中英

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.

git log
copy commit from there and then

git reset --hard "your commit"
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 -C master master~1
git push -f

From 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> .
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM