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

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

Asked on December 28, 2018 in Git.
Add Comment


  • 3 Answer(s)

    Here, replace repo with the contents of repo/.git.

    Run the commands:

    cd repo
    mv .git ../repo.git # renaming just for clarity
    cd ..
    rm -fr repo
    cd repo.git
    git config --bool core.bare true
    
    Answered on December 28, 2018.
    Add Comment

    The file structure of a bare repository gives what is inside the .git directory.

    git clone --bare /path/to/repo
    
    

    In order to neglect name conflict try it in different directory and then move wherever needed. Change the config file to check wherever origin repo is available.

    Answered on December 28, 2018.
    Add Comment

    This will be more efficient to the conversion:

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

    For more information see the GitFaq.

    Answered on December 28, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.