简体   繁体   中英

revert multiple branch merged to develop

So I have a branch named BRANCH_A and there is another branch named BRANCH_B which these two branchs merged to develop branch. Now something went wrong in BRANCH_A , it's looks like regression for some reasons, maybe bad merged, after this merge I had few minor commits also in BRANCH_A anyway I need to revert back BRANCH_A to a safe commit before this merged happened. I follow other similar issues posts in stack, and did this as below :

first inside BRANCH_A I create a backup branch :

git branch BACKUP_A

Then reset to SHA from yesterday, which is a commit just before that merged happened :

git reset --hard SHA

Then point the BRANCH_A to backup branch :

git reset --soft BACKUP_A

Then commit :

git commit -m "Revert to SHA id"

and pushed :

git push

This will revert to that commit, But the thing is, I still have other branch changes ( for BRANCH_B ) on that merge and this only revert back those minor commits that I did after merge.

How can I revert in a way that I get raid of those changes from other Branch ( BRANCH_B ) and only keep changes that I actually did in BRANCH_A ( the commit before merge ) .

So I was able to fix this issue by doing these :

Inside the branch_a that have issue :

Git reset —hard commitID
Git merge origin/develop
Git push -f

Then checkout develop and delete the branch_a

git checkout develop
git branch D branch_a

And checkout it again

git checkout branch_a

Hope it works for someone who face similar issue.

Note : Be careful when you run Git push -f because if you made a mistake you will loose your code

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