在amazon ec2上配置git

时间:2014-03-26 08:13:50

标签: git amazon-ec2

我正在尝试在amazon ec2上设置git并将其连接到我当地的ubuntu机器。所以这就是我所做的:

修改~/.ssh/config以添加我的服务器(我在那里添加了以下内容)

Host myServer
Hostname ec2- ... .compute.amazonaws.com
User ubuntu
IdentityFile /path/to/pem-key.pem

然后我使用ssh myServer ssh到我的服务器,使用sudo apt-get install git安装git,然后转到cd /var/www/设置我的git git init。我没有使用git init --bare因为我已经有了一些代码。

然后我试图在我的本地机器上设置git: git remote add production myServer:/var/www/(这是我的本地代码所在的位置,它有一些更改,因此它与ec2上的不同)。

到目前为止没有错误。但是当我尝试用git push推送我的本地代码时,我得到了:

  

从命令行指定URL或配置远程   存储库使用

git remote add <name> <url>
     

然后使用远程名称推送

git push <name>

好的,我正在尝试git push myServer,因为它写在第二个建议中(我已经完成了第一个建议),我收到了另一个错误:

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

fatal: 'myServer' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我完全迷失了,我认为我走错了路。我想要的只是设置git,以便能够在客户端上使用git pushgit commit在服务器上轻松推送我的本地更改,并在服务器上使用git pull进行部署。

当我尝试使用Michel的建议并在客户端上执行git remote -v时,我得到了

production  myServer:/var/www/ (fetch)
production  myServer:/var/www/ (push)

当我git push production default时,我得到了

error: src refspec default does not match any.
error: failed to push some refs to 'myServer:/var/www/

1 个答案:

答案 0 :(得分:0)

正确的推送语法是

git push <remoteName> <branchName>

您将远程“生产”命名为

git push production (<branch to push>)

将完成这项工作。

此外,您可以使用

验证您的遥控器
git remote -v