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

后端 未结 17 1208
礼貌的吻别
礼貌的吻别 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:17

    In short: replace the contents of repo with the contents of repo/.git, then tell the repository that it is now a bare repository.

    To do this, execute the following commands:

    cd repo
    mv .git ../repo.git # renaming just for clarity
    cd ..
    rm -fr repo
    cd repo.git
    git config --bool core.bare true
    

    Note that this is different from doing a git clone --bare to a new location (see below).

提交回复
热议问题