在AWS上设置远程git存储库并从Windows推送 [英] Setting a remote git repository on AWS and pushing from Windows
问题描述
我试图在AWS上的Ubuntu实例上创建一个远程存储库,然后从Windows上的本地存储库中推送.我遵循了此处的教程.
I am trying to create a remote repository on my Ubuntu Instance on AWS and then push from my local repository on Windows. I followed the tutorial here.
我遵循了以下确切步骤:
I followed these exact steps:
- 我在AWS上创建了一个Ubuntu实例.
-
我做了
ssh-add path/to/myKP.pem
. 它给了我一个错误Could-not-open-a-connection-to-your-authentication-agent
.
- I created an Ubuntu instance on AWS.
I did
ssh-add path/to/myKP.pem
. It gave me an errorCould-not-open-a-connection-to-your-authentication-agent
.
然后我运行此eval $(ssh-agent)
并再次执行步骤2.现在,它说已添加身份.
Then I ran this eval $(ssh-agent)
and did step 2 again. Now it said Identity added.
我用 myKP.pem 生成了一个.ppk文件,然后用它通过Putty将其SSH到我的ubuntu实例中.
I generated a .ppk file with myKP.pem and then used it to ssh into my ubuntu instance with Putty.
运行以下命令:apt-get update
和apt-get install git-core
.
mkdir repo.git
和cd repo.git
和git init --bare
然后从我的本地目录中运行git init
和git add .
和git commit -m "Init commit"
Then from my local directory I ran git init
and git add .
and git commit -m "Init commit"
git remote add origin ubuntu@publicIP:/repo.git
git config --global remote.origin.receivepack "git receive-pack"
.
git push origin master
.
然后我收到此错误:
fatal: 'ubuntu@publicIP/repo.git' 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.
有人可以告诉我在Ubuntu实例上创建一个空git存储库,然后从本地存储库中推送时应该遵循的步骤.
Can someone give tell me the steps I should follow to create an empty git repository on my Ubuntu instance and then push from my local repository.
注意,我正在使用Windows.
NOTE that I am using Windows.
编辑:我还需要将 .pem 文件存储在我的Ubuntu实例上吗?
Do I need to store my .pem file on my Ubuntu instance too?
对于某些人来说这真的很简单很抱歉,但是我是SSH和AWS的新手.
I am sorry if it's really easy for some people, but I am new to SSH and AWS.
推荐答案
说明似乎正确.以下步骤顺序应该可行.
The instructions seems correct. The below sequence of steps should work.
EC2实例
Install git if not available via apt-get (Ubuntu) or yum install (CentOS)
$ mkdir test-repo.git
$ cd test-repo.git
$ git init --bare
本地计算机ssh-add
这是设置EC2实例时指定的.pem文件.不必在EC2实例上.
This is the .pem file that was specified when setting up the EC2 instance. It does not need to be on the EC2 instance.
ssh-add path/to/local/ec2.pem
对于Windows,您可以下载适用于Windows的GitHub桌面.安装后,ssh-add
应该可用.遵循以下步骤,将ec2.pem
文件(私钥)添加到ssh auth agent
( Windows选项卡-部分:添加SSH ssh-agent的键)
For Windows, you can download GitHub Desktop For Windows. Once you have installed it, ssh-add
should be available. Follow these steps to add the ec2.pem
file (private key) to the ssh auth agent
(Windows tab - Section: Adding your SSH key to the ssh-agent)
将本地计算机推送到存储库
mkdir test-repo
cd test-repo
git init
echo "This is a test repo" > README.md
git add README.md
git commit -m "Added readme file"
git remote add origin ec2-user@aws-host-name-or-ip-here:/path/to/test-repo.git
git remote -v #for-verification
git config --global remote.origin.receivepack "git receive-pack"
git push origin master
这篇关于在AWS上设置远程git存储库并从Windows推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!