'Overwrote master with another branch completely when trying to merge, how to revert it?
I wanted to merge two branches into one, however instead I overwrote it.
On github desktop I went toolbar branch -> "Merge into current branch" on master, chose branch A then pushed it, and now it's as if branch A has been copied over into master without any trace at all of the previous master branch.
How do I revert it? There's no commit history of the merge at all & cant find anything about it.
Solution 1:[1]
Run git reflog master in a terminal, you will see a history of the previous states of your master branch.
To revert to a target commit :
from a clean worktree (e.g: git status indicates that there are no modified files and nothing to commit), you can use git reset --hard:
# switch to your master branch:
git checkout master
# move it to its previous state:
git reset --hard <sha>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
