How to remove working tree from a Git repository

前端 未结 2 1457
野性不改
野性不改 2021-01-04 14:24

I\'d like to convert my Git repository to a bare one. I distinctly remember something like git remove-tree that did the job previously but I can\'t find it on 1.7. Could you

相关标签:
2条回答
  • 2021-01-04 14:43

    git clone --bare old_directory new_directory

    0 讨论(0)
  • 2021-01-04 14:51

    Cloning your git repository, as suggested in Skydreamer's answer, may be fine for what you want, but it would lose remote-tracking branches, settings in .git/config, etc. An alternative is to just reuse the .git directory as a bare repository, e.g. by doing:

    cd my-repo
    mv .git ../my-repo.git
    cd ../my-repo.git
    git config core.bare true
    

    ... which will leave my-repo with just your working tree, and my-repo.git as a bare version of the same repository.

    0 讨论(0)
提交回复
热议问题