Skip to content

Instantly share code, notes, and snippets.

@matthewoden
Created May 22, 2016 17:48
Show Gist options
  • Select an option

  • Save matthewoden/b29353e266c554e04be8ea2058bcc2a0 to your computer and use it in GitHub Desktop.

Select an option

Save matthewoden/b29353e266c554e04be8ea2058bcc2a0 to your computer and use it in GitHub Desktop.

Revisions

  1. matthewoden created this gist May 22, 2016.
    34 changes: 34 additions & 0 deletions AWS Git Setup.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    # 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.
    ```bash
    ssh-add path/to/your/EC2.pem
    ```

    ## Set up destination directory:
    SSH into the remote directory, and create a barebones remote repo directory.
    ```bash
    ssh [email protected]
    mkdir repo-name.git && cd repo-name.git
    git init --bare
    ```

    ## Set up your local to push to our new remote:
    ```bash
    cd repo-name
    git init git add .
    git commit -m "Initial git commit message"
    git remote add origin [email protected]:/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.
    ```bash
    git clone [email protected]:/path/to/your/repo-name.git
    ```

    (This guide was lifted from [here](https://shirtdev.wordpress.com/2011/05/04/setting-up-a-git-repository-on-an-amazon-ec2-instance/), then modified slightly.)