Search code examples
gitgit-branchgit-plumbing

git refs/heads is a sub directory safe? here, or should it be somewhere else?


I have a series of branches with a prefix, I wish to reuse this prefix but not group them with the existing branches with this prefix (which are now obsolete). I Have for the time made a subdirectory in .git/refs/heads.

I want to know if there are any adverse side effects, or better recommendations for where to put a set of branch names to give them a prefix. They do not need to be cloned/pushed/pulled to any other repositories at this time, though such ability may be nice.

P.S. It would be nice if these branches remained easy to checkout as well.


Solution

  • I cannot see why you should not be able to just rename your branches with git branch -m $OLD_NAME $NEW_NAME. E.g say the prefix is test/ and you want to obsolete the msdos and minix test branches while keeping all the other test branches as is, but you still want to be able to access the obsoleted branches:

    $ git branch --all
    * master
      test/linux
      test/minix
      test/msdos
      test/openbsd
      test/windows
    $ git branch -m test/minix obsolete/test/minix
    $ git branch -m test/msdos obsolete/test/msdos
    $ git branch --all
    * master
      obsolete/test/minix
      obsolete/test/msdos
      test/linux
      test/openbsd
      test/windows
    $
    

    Update:

    Yes, those branches are sub directories under .git/refs/head

    $ find .git/refs/heads/ -type f
    .git/refs/heads/obsolete/test/msdos
    .git/refs/heads/obsolete/test/minix
    .git/refs/heads/test/openbsd
    .git/refs/heads/test/linux
    .git/refs/heads/test/windows
    .git/refs/heads/master
    $