简体   繁体   中英

Configuring git on amazon ec2

I am trying to set up git on amazon ec2 and connect it to my local ubuntu machine. So here is what I have done:

modified ~/.ssh/config to add my server (I added the following there)

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

Then I ssh to my server with ssh myServer to install git with sudo apt-get install git and go to cd /var/www/ to set up my git with git init . I am not using git init --bare because I already have some code there.

Then I am trying to set up git on my local machine: git remote add production myServer:/var/www/ (here is where my local code is and it is with some changes so it is not the same as on the ec2).

Up till now there are no errors. But when I try to push my local code with git push I am getting:

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> 

Ok, I am trying git push myServer , as it is written in the second suggestion (I already done the first one), I am getting another error:

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.

I am totally lost and I think that I am on the wrong track. All I want is to setup git to be able to easily push my local changes on the server with git push , git commit on the client and deploy them with git pull on the server.

When I try suggestions of Michel and do git remote -v on the client, I get

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

When I do git push production default I get

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

The correct syntax for pushing is

git push <remoteName> <branchName>

You named your remote "production", so

git push production (<branch to push>)

will do the job.

Additionally you can verify your remotes using

git remote -v

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM