Git:将现有存储库从 PC 移动到服务器,从服务器克隆
我的本地计算机上有一个现有的 Git 存储库。我想将该存储库移至我的 Web 服务器,然后在本地计算机上使用 git clone 来从服务器查看我的存储库。我计划在本地计算机上进行开发并将更新推送回服务器。我可以从本地计算机通过 ssh 连接到服务器,但反之则不行。我该怎么办?我认为 git bundle 应该以某种方式使用,不过,当我尝试在服务器上 git clone 我的包时,我收到了“警告:远程 HEAD 引用不存在的引用,无法签出”错误。我的本地计算机运行 OS X,服务器运行 Linux。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Linux 服务器上的新目录中执行以下操作:
然后在本地计算机上:
之后,服务器将拥有存储库的完整副本,您将能够对其进行推送和拉取。当您在本地已有一个克隆时,无需从服务器检查另一个克隆。
On the Linux server, in a new directory do:
Then on your local machine:
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 Push --all origin”代替“git Push origin master”,这样您就可以移动所有分支,而不仅仅是主分支。
Instead of "git push origin master" use "git push --all origin" so that you move over all branches and not just the master branch.
怎么样:
这会将数据从本地存储库发送到您的服务器。然后执行以下操作:
然后您将从服务器克隆。满意后,您可以删除原始存储库,并可能重命名第二个存储库。
How about this:
That will send the data from your local repo to your server. Then do this:
Then you will have cloned from the server. When satisfied, you can get rid of the original repo, and possibly rename the second one.