2

I have a repo on my laptop and I want to push it to a remote repo on AWS EC2. This is how I build this. I upload my laptop repo on github. The repo on the EC2 was cloned from github. But I did a lot of config on the EC2 so I put some file in .gitignore. I want to update some my new code on my laptop to EC2 so I want to push the code to repo on EC2 directly.

This is what I did to push: I used MacOS, and I edit ~/.ssh/config and add

Host Vidaminds_server
Hostname www.vidaminds.com
User ubuntu
IdentityFile ~/Downloads/Vidaminds.pem

And I used this command:

git remote add Vidaserver2 Vidaminds_server:~/Vidaminds/.git
git push Vidaserver2 master

It shows:

shen-3:New Platform shen$ git push -f Vidaserver2 master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 507 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
To Vidaminds_server:~/Vidaminds/.git
   4cfe6da..7a6a4a8  master -> master

The dir on the EC2 is /home/Vidaminds/ and there is a .git file in the folder. After I push it to EC2 my laptop shows it success but I didn't see my file change. I don't know if there is any error what I did. Thanks!

1 Answers1

0

Pushing to the .git folder alone won't update the working tree content ~/Vidaminds.

On EC2, try (after the push)

cd ~/Vidaminds
git checkout -- .

In order to force the working tree to reflect the new branch history (assuming here, for instance, that you have pushed master)

You could also set up your EC2 repo to accept a push-to-deploy, allowing you to push directly to that non-bare repo.

Anshul Goyal
  • 61,070
  • 31
  • 133
  • 163
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283