Rob
Rob

Reputation: 78598

Creating a copy of local git repository on a remote server

I have cloned a project from a server using git clone and I now want to copy it (all branches) to another server so other people can start using it. I guess I could simply copy the entire repository manually and then issue git config --bool core.bare true and delete everything but the .git folder but I don't think that qualifies as a 'bare' repository and I'm worried it might give me problems.

I was hoping I could create the new remote repository using git init --bare and simply push my local one to it but as I originally cloned my local copy from another server, the origin seems to be blocking me from doing this.

Upvotes: 34

Views: 20620

Answers (2)

Roman Cheplyaka
Roman Cheplyaka

Reputation: 38708

  1. Create a fresh bare repository on the server:
    git init --bare newrepo.git
  2. Add it as a remote in your local repo:
    git remote add newrepo git://[email protected]/newrepo.git
  3. git push newrepo master to push a particular branch, or
    git push --all newrepo to push all branches

Upvotes: 51

gahooa
gahooa

Reputation: 137252

Another way is (as you wished):

git clone --bare /path/to/repo newrepo.git

Upvotes: 13

Related Questions