How to convert a normal Git repository to a bare one?

后端 未结 17 1219
礼貌的吻别
礼貌的吻别 2020-11-22 08:05

How can I convert a \'normal\' Git repository to a bare one?

The main difference seems to be:

  • in the normal Git repository, you have a .git

17条回答
  •  不知归路
    2020-11-22 08:23

    Oneliner for doing all of the above operations:

    for i in `ls -A .`; do if [ $i != ".git" ]; then rm -rf $i; fi; done; mv .git/* .; rm -rf .git; git config --bool core.bare true
    

    (don't blame me if something blows up and you didn't have backups :P)

提交回复
热议问题