Search code examples
gitversion-controlgit-revert

Effects of Git revert on undoing merged & deleted branches


If I merged a branch with master branch with normal merge & not fast-forward merge. Then I deleted the branch merged. At a later stage I want to revert back to a commit before merging the two branches. Will git let me do it if there are no conflicts. If yes then will it bring back the deleted branch?


Solution

  • If what you are asking if whether the branch (as in, a revision pointer) will be recreated after you deleted it, the answer is no. But I'm talking about the pointer here. So... just so that it's clear. Let's assume the branch that you merged was called foo. After you merged it, you did: git branch -d foo. Now branch foo(the pointer) is gone but the revision that it was pointing to is not deleted at all (actually, it's now part of your branch). So if you now start reverting up to a point before the merge, you won't see a branch named foo come back from the dead.