如何将远程Git存储库添加到Ubuntu服务器? [英] How do I add a remote Git repository to an Ubuntu Server?
问题描述
我已经在台式机(Windows 7)上使用以下命令创建了一个Git存储库:
I have created a Git repository on my Desktop machine (Windows 7) with:
git init
git add <all my files>
git commit -m "added my files"
现在,我已在局域网上的计算机上安装了新的Ubuntu Server 10.10,并安装了OpenSSH.我的主目录是/home/jonas
,我创建了一个目录~/code/
来包含我的项目.我可以使用Putty从Windows 7登录到Ubuntu服务器.
Now I have installed a new Ubuntu Server 10.10 on a machine on my LAN and installed OpenSSH. My home directory is /home/jonas
and I created a directory ~/code/
to contain my projects. I can log in to the Ubuntu Server from Windows 7 with Putty.
我使用sudo apt-get install git
现在,我要将我的桌面上的Git存储库添加到服务器.我尝试按照使用Git进行实用版本控制中的说明进行操作.
Now I want to add my Git repository on my Desktop to the Server. I tried to follow the instructions from Pragmatic Version Control Using Git.
在我的桌面上,运行以下命令:
From my Desktop I run these commands:
git remote add origin jonas@192.168.1.10/home/jonas/code/myproject.git
git push origin master
但是我收到此错误消息:
But I got this error message:
fatal: 'jonas@192.168.1.180/home/jonas/code/myproject.git' does not appear to be
a git repository
fatal: The remote end hung up unexpectedly
是什么问题?如何创建远程存储库?
按照PerfectlyNormal的建议,我在地址中添加了:
.现在它可以更好地工作了,我不得不在服务器上输入密码,但是随后出现了类似的错误消息:
As PerfectlyNormal suggested, I added a :
in the address. Now it worked better, and I had to type my password to the server, but then I got a similar error message:
fatal: '/home/jonas/code/myproject.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
我必须先在服务器上初始化Git存储库,然后才能git push
进行访问吗?
Do I have to initialize a Git repository on the server before I can git push
to it?
推荐答案
您是否在远程服务器上设置了存储库?您需要运行
Did you setup the repository on the remote server? You need to run
mkdir -p /home/jonas/code/myproject.git
cd /home/jonas/code/myproject.git
git init --bare
在服务器上按
进行设置.我建议您看看如何在免费的 ProGit图书中设置git服务器.
on the server in order to set it up. I recommend taking a look at how to setup a git server in the free ProGit book.
这篇关于如何将远程Git存储库添加到Ubuntu服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!