2011-07-19

Switching the active branch in a bare git repository

If you ever need to delete the "active" branch in a git repository, you need to first switch the active branch. Because you cannot delete the branch you are sitting on... You cannot checkout a branch, as you would usually do. You have to change the symbolic reference called HEAD. You can do this with the symbolic-ref command:

$ git branch
* deletethis
  somebranch
$ git symbolic-ref HEAD refs/heads/somebranch
$ git branch
  deletethis
* somebranch
$ git branch -d deletethis

No comments:

Post a Comment