Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a working copy of a bare repository

I have a server on which I have a bare repository for pushing. However, my server needs to have a working copy of the master branch.

How do I get a working copy and that only from a bare repository?

like image 935
Jonathan Allard Avatar asked Sep 16 '12 20:09

Jonathan Allard


People also ask

Can you pull from a bare repository?

A bare repo is characterized by not having a working copy in the file system. Therefore no file on the disk of a bare repo can be part of the repo, and you can't pull it as a result.

Can I clone a repository without git?

Degit is a tool created by Rich Harris, the creator of Svelte and Rollup, which he uses to quickly create a new project by cloning a repository without keeping the git folder. But it can also be used to clone any repo once...


1 Answers

You can simply clone the repository to another directory on the same machine:

git clone /bare/repo/dir 

The current directory will become a non-bare clone of your repo, and you'll get a checkout of the master branch automatically. Then use the usual commands like git pull to update it as needed.

As a side benefit, this operation is very efficient — if you specify a local directory to git clone, git will use hard links to share the read-only parts of the object databases of the two repos.

like image 55
user4815162342 Avatar answered Sep 19 '22 08:09

user4815162342