简体   繁体   English

如何将现有的Git存储库克隆到远程Gitolite服务器?

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

I am using Gitolite on a remote machine to access my repositories. 我在远程机器上使用Gitolite来访问我的存储库。

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. 我可以使用Gitolite在远程机器上设置一个新的空存储库,在特殊的gitolite-admin项目中编辑conf/gitolite.conf When I push the configuration to the remote machine Gitolite automatically creates the new bare repository. 当我将配置推送到远程机器时,Gitolite会自动创建新的裸存储库。

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? 我打算如何与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. git clone命令创建一个克隆。 Since the location you specified gitolite@server:test.git is already a Git repository, you cannot create a clone on top of it. 由于您指定的位置gitolite@server:test.git已经是Git存储库,因此您无法在其上创建克隆。 This is not what you really want here. 这不是你真正想要的。

What you need to do is push your local repository to gitolite. 您需要做的是将您的本地存储库推送到gitolite。 Assuming you are in the directory of your local repository, you can push it to gitolite using the following steps: 假设您位于本地存储库的目录中,可以使用以下步骤将其推送到gitolite:

# 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。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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