Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 无法从本地ubuntu计算机推送到aws ec2_Git_Amazon Web Services_Ubuntu_Amazon Ec2_Git Bare - Fatal编程技术网

Git 无法从本地ubuntu计算机推送到aws ec2

Git 无法从本地ubuntu计算机推送到aws ec2,git,amazon-web-services,ubuntu,amazon-ec2,git-bare,Git,Amazon Web Services,Ubuntu,Amazon Ec2,Git Bare,我试图使用git推送到aws ec2实例,但总是出现以下错误: error: pack-objects died of signal 13 error: failed to push some refs to ssh://ubuntu@..../..../myrepo.git 我所做的: 1-在我的ec2服务器(ubuntu 18.04)上创建git裸机存储库 2-在我的本地计算机(ubuntu 16.04)中: a-在~/.ssh/中添加myserverkey.pem b-将以下内容添加到.

我试图使用git推送到aws ec2实例,但总是出现以下错误:

error: pack-objects died of signal 13
error: failed to push some refs to ssh://ubuntu@..../..../myrepo.git
我所做的:

1-在我的ec2服务器(ubuntu 18.04)上创建git裸机存储库

2-在我的本地计算机(ubuntu 16.04)中:

a-在~/.ssh/
中添加myserverkey.pem b-将以下内容添加到.ssh/config

Host myserver
Hostname myserverpublicdns
User ubuntu
IdentityFile ~/.ssh/myserverkey.pem
c-在我的项目目录中,我执行了以下操作:

git init
git remote add origin myserver:/~/path/to/myrepo.git
git add .
git commit -m 'test commit'
git push origin master
还有,我试过了

git remote add origin ssh://ubuntu@myserverpublicdns/home/../path/to/myrepo.git
当我推送到服务器时,它会给出同样的错误

错误是:

Counting objects: 547, done.
Delta compression using up to 4 threads.
Compressing objects : 100% (530/530), done.
error: pack-objects died of signal 13
error: failed to push some refs to ssh://ubuntu@..../..../myrepo.git
我找不到任何解决我的问题的办法

请注意,我的项目大小只有4.5mb,我可以使用以下方式连接到服务器:

ssh myserver
这意味着.ssh/config文件中没有错误

那么问题出在哪里??我做错了什么??


提前谢谢

行中myserver的分辨率:

git remote add origin myserver:/~/path/to/myrepo.git
可能无法工作,因为“myserver”必须由/etc/hosts文件解析,否则git将找不到您的服务器

您的ssh命令之所以有效,是因为您的ssh配置文件在myserver和实例的主机名之间建立了链接

(如果不想在每次停止实例时更新配置,请在实例上设置弹性ip)

您还应该拥有look to folder权限,您正在连接ubuntu用户,确保它在git存储库路径上具有正确的权限

不要在文件夹上设置777,永远不要。而是创建一个组:

groupadd mygitgroup
然后将用户ubuntu添加到此组中

usermod -aG mygitgroup ubuntu 
将git reposity的正确位置设置为组:

chgrp -R mygitgroup /my/git/path
删除无效的权限

chmod 770 /my/git/path

您好,我还尝试了以下操作:git remote add originssh://ubuntu@serverpublicdns.com/home/../path/to/myrepo.git,它给出了相同的错误@MB81 git repo存储在/home/ubuntu中?如果它在另一个用户文件夹中,perharp会有一个基本的权限问题?实际上,这是服务器上的权限问题,当我将myrepo.git的权限更改为777时,一切都很顺利。什么是更好的练习呢?谢谢@MB81这就是我要找的!
chmod 770 /my/git/path