Skip to content

Instantly share code, notes, and snippets.

@kbzaso
Forked from matthewoden/AWS Git Setup.md
Created July 6, 2017 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbzaso/8fd5d95adc2350c3c8c6f02815704f9c to your computer and use it in GitHub Desktop.
Save kbzaso/8fd5d95adc2350c3c8c6f02815704f9c to your computer and use it in GitHub Desktop.
Setting up a remote Git in AWS EC2

AWS Remote Git Setup

Get a local git repo up on an EC2 Instance.

Add youself to SSH Authentication:

Add yourself to the ssh auth agent, if you haven't already.

ssh-add path/to/your/EC2.pem

Set up destination directory:

SSH into the remote directory, and create a barebones remote repo directory.

ssh ec2Username@long-crazy-amazon-ip.com 
mkdir repo-name.git && cd repo-name.git 
git init --bare

Set up your local to push to our new remote:

cd repo-name 
git init git add . 
git commit -m "Initial git commit message" 
git remote add origin ec2Username@long-crazy-amazon-ip.com:/path/to/your/repo-name.git 
git config --global remote.origin.receivepack "git receive-pack" # needed for aws ec2 stuff.
git push origin master

Cloning repository

The origin url can be used for cloning too.

git clone ec2Username@long-crazy-amazon-ip.com:/path/to/your/repo-name.git 

(This guide was lifted from here, then modified slightly.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment