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

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

    Here's what I think is safest and simplest. There is nothing here not stated above. I just want to see an answer that shows a safe step-by-step procedure. You start one folder up from the repository (repo) you want to make bare. I've adopted the convention implied above that bare repository folders have a .git extension.

    (1) Backup, just in case.
        (a) > mkdir backup
        (b) > cd backup
        (c) > git clone ../repo
    (2) Make it bare, then move it
        (a) > cd ../repo
        (b) > git config --bool core.bare true
        (c) > mv .git ../repo.git
    (3) Confirm the bare repository works (optional, since we have a backup)
        (a) > cd ..
        (b) > mkdir test
        (c) > cd test
        (d) > git clone ../repo.git
    (4) Clean up
        (a) > rm -Rf repo
        (b) (optional) > rm -Rf backup/repo
        (c) (optional) > rm -Rf test/repo
    

提交回复
热议问题