簡體   English   中英

在Amazon EC2上配置git

[英]Configuring git on 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並轉到cd /var/www/git init設置我的git。 我沒有使用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 push ,客戶端上的git 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/

推送的正確語法是

git push <remoteName> <branchName>

您將遠程命名為“生產”,因此

git push production (<branch to push>)

會做的工作。

此外,您可以使用以下方式驗證您的遙控器

git remote -v

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM