Ein Streifen über Interaktivität, Webentwicklung und Musik, i think.

March 2, 2010 at 7:30pm


recovering a deleted branch using git reflog

So after finishing something on a topic branch called “gamelan”, i wanted to switch back to the master branch, so this is what i just did:

$ git checkout master
$ git branch -D gamelan

Shoot! Now in a i just deleted the branch without merging it beforehand. (Why, but why!?). Fortunatly Git has some divine powers which can help you recover. Git records your changes in a log, which you can show using git reflog:

$ git reflog
bc2ff27 HEAD@{1}: checkout: moving from gamelan to master
2cf094f HEAD@{2}: commit: WIP klangreihe gibt Noten zurück. Thread Beispiele
8592aac HEAD@{3}: commit: WIP mehrere stimmen über gamelan scheduler

These commits are still “somewhere out there”. So to merge the changes from the deleted branch, i just merged the last commit from the deleted branch:

$ git merge 2cf094f

Mmmh git.


  1. bank-konto-kostenlos reblogged this from ahx
  2. ehlyzov reblogged this from ahx
  3. ahx posted this