Using Amazon S3 as your private git repository

Been trying to move my git repositories and apps from my old (and expensive) VPS into Amazon’s EC2 when I asked myself whether it is possible to push use Amazon S3 as a git repository.

Some searching later, I found out the answer. YES!

It is not only possible to push your repositories into your S3 bucket, but its also possible to do so even when your bucket is in a non-US region.

The only real thing that you’d need to install is JGit, a java implementation of the git client.

Here’s a quick and dirty guide from my experience:

  1. Download and put it in a path that bash is already reading from.
# when you download your jgit from the link above, its typically in 
# a format like
# rename that just to jgit and put it in a path-readable directory

# you may need to sudo

[email protected]:/usr/local/bin> ls

[email protected]:/usr/local/bin> chmod +x jgit


2. Prepare your AWS security credential keys and create a .jgit file in your ~/.jgit
[email protected]:~> vim .jgit

# Add the following
accesskey: aws access key
secretkey: aws secret access key
3. Chmod 600 your .jgit file
[email protected]:~> chmod 600 .jgit
4. Create an S3 bucket in your AWS Console 5. You're set!
# .jgit could be any file you designate as your
[email protected]:/home/me/awesomecode> git remote add s3 amazon-s3://[email protected]/.git

# push away
[email protected]:/home/me/awesomecode>  jgit push s3 master

While this is great for hosting personal code where you're the only developer, this is not that useful for multi-developer environments.

Your S3 bucket is set to ACL: private by default so its only accessible by you. If you'd like to make it accessible to the public (to download), in your ~/.jgit add the following line after your secret key:
acl: public
The public can then clone your repository by
git clone

Caveats: You cannot push to a S3 repository via http. You'd still need to make use of jgit and the amazon-s3 protocol.

Hope this helps!