0

I have a site running on an EC2 instance. Statamic is a simple cms built to run with no DB. It uses yml files for content storage.

This is great but if anyone changes any remote content in the cms and we do a git push we lose the updated content because it gets overwritten.

We also make occasional changes locally.

My EC2 instance has git loaded and I can run a pull from my bitbucket repo and that works great. However, I'd like to be able to pull from the EC2 instance to make sure I have content all up to date.

How can I add the EC2 instance as a remote from my local?

TIA

TJ Sherrill
  • 2,465
  • 7
  • 50
  • 88
  • 1
    If I understand correctly you have 3 repos: local working copy, Bitbucket and EC2 instance. You push to Bitbucket, right? Otherwise, you already have EC2 as remote from your local. – Daemon Painter Apr 28 '20 at 23:46
  • Correct. Due to how the cms use static files I need to pull content updates before pushing code updates. – TJ Sherrill Apr 29 '20 at 15:18

1 Answers1

1

You can totally use EC2 instance as a remote.

Two tricks here:

1) use ssh://... for repo address.

2) on your local host add ec2 private key with ssh-add

$ ssh-add <path-to-ec2-ssh-key>.pem
$ git remote add ec2 ssh://ec2-user@<amazon-server-address>/<repo-path.git>

See the complete example: https://gist.github.com/aviaryan/393fbb7d96b133d6dfbd430a21c5e73b

Anton
  • 3,587
  • 2
  • 12
  • 27