Posted By: Anonymous
I need to create a central Git repository but I’m a little confused…
I have created a bare repository (in my git server, machine 2) with:
$ mkdir test_repo $ git --bare init
Now I need to push files from my local repository (machine 1) to the bare repository (machine 2). I have access to machine 2 by SSH. The thing is that I think I don’t understand the concept of a bare repository…
What is the right way of storing my code in the bare repository? How can I push changes from my local repository to the bare repository?
Is the right way of having a central repository to have a bare repository?
I’m a little confused with this subject. Please give me a clue on this.
Firstly, just to check, you need to change into the directory you’ve created before running
git init --bare. Also, it’s conventional to give bare repositories the extension
.git. So you can do
git init --bare test_repo.git
For Git versions < 1.8 you would do
mkdir test_repo.git cd test_repo.git git --bare init
To answer your later questions, bare repositories (by definition) don’t have a working tree attached to them, so you can’t easily add files to them as you would in a normal non-bare repository (e.g. with
git add <file> and a subsequent
You almost always update a bare repository by pushing to it (using
git push) from another repository.
Note that in this case you’ll need to first allow people to push to your repository. When inside
git config receive.denyCurrentBranch ignore
git init --bare --shared=group
As commented by prasanthv, this is what you want if you are doing this at work, rather than for a private home project.