Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When creating a git repository that will be on the server, can I convert it to a bare repository? [duplicate]

I already created a repository. Can I make it a bare type or shall I start over?

like image 778
mrblah Avatar asked Nov 23 '09 16:11

mrblah


People also ask

How do I duplicate a repository in GitHub?

On GitHub.com, navigate to the main page of the repository. Above the list of files, click Code. Click Open with GitHub Desktop to clone and open the repository with GitHub Desktop. Follow the prompts in GitHub Desktop to complete the clone.

How do I clone a git repository on a server?

To Git clone a repository navigate to your preferred repository hosting service like GitHub, select the repository you want to clone, copy the repository URL via HTTPS or SSH, type git clone in the command line, paste the URL, and hit enter .

What is bare git repository?

What is a bare repository? A bare repository is the same as default, but no commits can be made in a bare repository. The changes made in projects cannot be tracked by a bare repository as it doesn't have a working tree. A working tree is a directory in which all the project files/sub-directories reside.


2 Answers

According to the FAQ, conversion from non-bare to bare can be done in two ways. The best one:

$ git clone --bare -l repo repo.git $ rm -rf repo 

To create a bare repository from scratch:

$ mkdir repo.git $ cd repo.git $ git --bare init 
like image 76
Jørn Schou-Rode Avatar answered Oct 06 '22 11:10

Jørn Schou-Rode


Just move the .git folder away from the working copy.

mv /var/git/repo/repo/.git /var/git/repos/repo.git 

You might want to follow that up with a

git config --bool core.bare true 

in that repository, just in case git complains about something not being right.

like image 34
Bombe Avatar answered Oct 06 '22 11:10

Bombe