0
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?

Liem
  • 446
  • 1
  • 6
  • 20

1 Answers1

1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250