简体   繁体   中英

How to clone an existing Git repository to a remote Gitolite server?

I am using Gitolite on a remote machine to access my repositories.

Remote -> Local

Normally everything works fine: I create a new repository on the remote machine, clone it to my local machine and start working.

Local -> Remote

Now I have a local repository which is not on the remote machine. I can setup a new empty repository on the remote machine using Gitolite, editing conf/gitolite.conf in the special gitolite-admin project. When I push the configuration to the remote machine Gitolite automatically creates the new bare repository.

remote: Initialized empty Git repository in /var/lib/gitolite/repos/test.git/

Now I try to clone the exising repository from my local machine to the remote machine at once using the following command.

$ git clone --bare test gitolite@server:test.git

This fails with the following error message:

fatal: destination path 'gitolite@server:test.git' already exists \
       and is not an empty directory.

How am I meant to work with Gitolite? Since it automatically creates the new empty bare repository for me there should be a way to start from the local machine as well...

The git clone command creates a clone. Since the location you specified gitolite@server:test.git is already a Git repository, you cannot create a clone on top of it. This is not what you really want here.

What you need to do is push your local repository to gitolite. Assuming you are in the directory of your local repository, you can push it to gitolite using the following steps:

# Create a *remote* to point to your gitolite repo
git remote add gitolite gitolite@server:test.git

# Push to the gitolite remote and start tracking
git push -u gitolite master

将新repo配置为本地远程,然后推送所有分支和所有标记 - presto。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM