我想在amazon ec2上設置git並將其連接到我的本地ubuntu機器上。因此,這裏是我做了什麼:在亞馬遜ec2上配置git
修改~/.ssh/config
加入我的服務器(我增加了以下有)
Host myServer
Hostname ec2- ... .compute.amazonaws.com
User ubuntu
IdentityFile /path/to/pem-key.pem
然後我ssh到我的服務器ssh myServer
與sudo apt-get install git
安裝Git和去cd /var/www/
到用git init
設置我的git。我沒有使用git init --bare
,因爲我已經有一些代碼。
然後我試圖在我的本地機器上設置git: git remote add production myServer:/var/www/
(這裏是我的本地代碼所在,它有一些變化,因此它與ec2不一樣)。
到目前爲止沒有錯誤。但是,當我試圖把我的本地代碼git push
我越來越:
Either specify the URL from the command-line or configure a remote repository using
git remote add <name> <url>
and then push using the remote name
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
進行部署。
當我嘗試米歇爾的建議,並在客戶端上做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的遙控器-v'是'git的遠程-v'驗證您的遙控器? –
請看看我的編輯。 –
如果您尚未定義任何分支,請嘗試'git push production',也可以查看http://nvie.com/posts/a-successful-git-branching-model/和http:// blog .sourcetreeapp.com/2012/08/01/smart-branching-with-sourcetree-and-git-flow/ –