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?
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.
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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With