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.