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:
- Download jgit.sh 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
-jgit.sh # rename that just to jgit and put it in a path-readable directory # you may need to sudo [email protected]:/usr/local/bin> ls jgit [email protected]:/usr/local/bin> chmod +x jgit </pre> 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 key3. Chmod 600 your .jgit file[email protected]:~> chmod 600 .jgit4. 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://.jgit@ / .git # push away [email protected]:/home/me/awesomecode> jgit push s3 master </pre> Extra: 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: publicThe public can then clone your repository bygit clone http:// .s3.amazonaws.com/ .git </pre> 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!