Git:将现有存储库从PC移动到服务器,从服务器克隆 [英] Git: move existing repository from PC to server, clone from server

查看:208
本文介绍了Git:将现有存储库从PC移动到服务器,从服务器克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地机器上有一个现有的Git存储库。我想将该存储库移动到我的Web服务器,然后在我的本地计算机上的 git clone 从服务器检出我的存储库。我计划在我的本地机器上进行开发,并将更新推送到服务器。我可以从我的本地机器到服务器,但不是反之亦然。我应该怎么做呢?我认为 git bundle 应该以某种方式使用,虽然当我试图 git clone 我的服务器上的我的包,我有一个警告:远程HEAD指的是不存在的参考,无法检出错误。

I have an existing Git repository on my local machine. I would like to move that repository to my web server, then git clone on my local machine to check out my repository from the server. I'm planning on then developing on my local machine and pushing updates back to the server. I can ssh from my local machine to the server, but not vice versa. How should I go about this? I think git bundle should be used somehow, though when I tried to git clone my bundle on my server, I got a "warning: remote HEAD refers to nonexistent ref, unable to checkout" error. My local machine is running OS X, the server is running Linux.

推荐答案

在Linux服务器上,在一个新目录中执行:

On the Linux server, in a new directory do:

git init --shared --bare

然后在您的本地计算机上:

Then on your local machine:

git remote add origin server:path/to/repo
git push --all origin

之后,服务器将有一个完整的副本的存储库,你将能够推和拉它。当您已经在本地有一个克隆时,无需从服务器检出另一个克隆。

After that, the server will have a full copy of the repository, and you will be able to push and pull to and from it. There's no need to check out another clone from the server when you've already got one locally.

这篇关于Git:将现有存储库从PC移动到服务器,从服务器克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆