Liem
Liem

Reputation: 456

Git - how to roll back merge action?

master branch
feature branch: created from master branch
dev branch: created from feature branch

I merged dev branch to feature branch by mistake, now I have to roll back feature branch. So how can I do that?

Upvotes: 0

Views: 80

Answers (1)

VonC
VonC

Reputation: 1329292

If you just did the merge (of dev to feature), you could "Undo a Git merge that hasn't been pushed yet" with a git reset, especially if you have not pushed the feature branch yet.

git switch feature
git reset --hard HEAD~1

Make sure you don't have any work in progress.
And check with git log --decorate --oneline --graph --branches that your feature branch history is indeed showing the merge commit as the most recent one.

Upvotes: 1

Related Questions