How do I make existing non-bare repository bare?

作者 by adtxl / 2021-06-21 / 暂无评论 / 525 个足迹

1.stackoverflow

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

2.How do I make existing non-bare repository bare?

https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_make_existing_non-bare_repository_bare.3F

After making sure that there are no uncommitted changes, etc.:

$ mv repo/.git repo.git
$ git --git-dir=repo.git config core.bare true
$ rm -rf repo

The problem with the above process is that it doesn't take into account future internal changes of Git. A safer method is to let Git handle all the internal settings for you by doing something like this.

* ssh to remote server
* git clone --bare -l <path_to_repos> <new_dir>
* renamed old repository directory
* renamed new repository dir to what old repository used to be.
other

git config --bool core.bare false
git config --bool core.bare true

独特见解