Storing Git Repositories at Amazon S3 on Windows


if you have number of files need version control, you may heard about what is Git able to provide. Git is a mature version control system widely use by many peoples around the world. Storing repository online can be achieve using GitHub. There are free version for public repositories and pay version for private repositories. Other option is using Amazon AWS with local git. Amazon simple storage service (S3) is a online storage service that provide storage for your data and can be access from anywhere as long you have internet access. We are going to explore the way to store git repositories to Amazon S3 in this article.


*   Amazon [AWS]( account (There are free tier service to explore)
* download [here](

Install Jgit on Windows

Download file and store in your user directory.

  • Store file to your home directory. For example C:\Users\username\jgit
  • Create jgit.bat file using notepad and save on same directory
  • Fill jgit.bat file with line below java -cp %~dp0\ org.eclipse.jgit.pgm.Main %*
  • Save
  • Update Windows Environment Variable Path with jgit directory
  • Test jgit version

Below is screen shot on jgit version.  

Create Repository

Create directory in your machine where version control is needed. In my case I just put hello.txt file contain “Hello Word”.  

  • Store file to your home directory. For example C:\Users\username\jgit
  • Create directory repo-test // create repo-test directory
  • cd repo-test // browse to repo-test directory
  • Create text file hello.txt contain “Hello World” and save at repo-test directory

Initialized and add file to local repository. This is a process I am using on my laptop.

  • C:\Users\daddy\jgit\repo-test>jgit init
  • —– This is a response I got —-
  • C:\Users\daddy\jgit\repo-test>java -cp C:\Users\daddy\jgit\ org.eclipse.jgit.pgm.Main init
  • Initialized empty Git repository in C:\Users\daddy\jgit\repo-test.git
  • —————————–
  • C:\Users\daddy\jgit\repo-test>touch README
  • C:\Users\daddy\jgit\repo-test>jgit add *
  • —– This is a response I got —–
  • C:\Users\daddy\jgit\repo-test>java -cp C:\Users\daddy\jgit\ org.eclipse.jgit.pgm.Main add *
  • ——————————
  • C:\Users\daddy\jgit\repo-test>jgit commit -m “this is initial”
  • —— This a response I got —-
  • C:\Users\daddy\jgit\repo-test>java -cp C:\Users\daddy\jgit\ org.eclipse.jgit.pgm.Main commit -m “this is initial” [master ea01c727bd0e0c05ccaa2e15fa8fbbd90d5083b1] this is initial * C:\Users\daddy\jgit\repo-test><

Create Amazon S3 Bucket

After you sign up with Amazon AWS, you will have access to create S3 bucket. Let us call it “testbucket1010”. In order to save money you may want to add lifecycle rule to your Amazon bucket. Set the rule to transfer your S3 files to cheaper storage solution - Amazon Glacier, after certain period. I set mine after 1 day. Browse to Security Credential to get your amazon secret key and access key need on this process (root access). You may want to setup IAM user and use its key instead to prevent root access. Create text file contain your Amazon secret key and use acl to keep it private.

  • accesskey: xxxxxxxxxxxxxxxxxxxxxxx
  • secretkey: xxxxxxxxxxxxxxxxxxxxxxxxx
  • acl: private

Save the file on your Home directory. In my case on C:\Users\daddy Now, go back to repository we created.  

  • // secret is file contain accesskey
  • // testbucket1010 is Amazon bucket on S3

  • C:\Users\daddy\jgit\repo-test>jgit remote add origin amazon-s3://[email protected]/repo-test.git

  • C:\Users\daddy\jgit\repo-test>jgit push origin master

I used gitbucket01 as my Amazon bucket on this screen shot. Open browser, login to your Amazon S3 account and find your files on “testbucket1010”  bucket. There are several free Amazon S3 client available online you can use.

Retrieve Repository from Amazon AWS

Retrieve repository is a simple process. Go to other directory, let say c:/temp.  

  • :\Users\daddy\jgit\repo-test>jgit init // Create repository
  • cd c:\temp
  • jgit clone amazon-s3://[email protected]/repo-test.git

Browse to c:\temp you should see your files.  

Update/Download Local Repository From S3

After initial retrieved you may want to update your local directory in case there are newer files straight from remote S3 repository.

  • cd c:/temp/repo-test // Browse to working directory

  • Jgit fetch // update repo-test directory

Update Local Repository Files for Any Change

Update files is simple process. Just type

– $ jgit add * // Add new files if any

– $ jgit commit -m “This is an Update” // Commit local repository

– $ jgit push origin master // Upload to S3


If you have git (not jgit) windows installed in your machine, you can use it for git repository process except the part you want to push it to Amazon S3 you have to use Jgit.

Working With Local Branch

So far we are working with master branch. Sometime we want to  make some adjustment, add more feature to master branch and when everything stable we want to merge it back to master branch. To create a branch call “features” for example follow these steps.

– Jgit branch features // This command will create branch features

– Jgit branch // To list all branches

– Jgit checkout features // Switch to branch features

– Jgit commit -m “this is feature branch” // Commit change to feature branch

– Jgit push origin // Push to S3


View Branches From S3

VIew all branches from S3 follow these steps

– cd c:/temp

– jgit clone amazon-s3://[email protected]/repo-test.git

– cd c:/temp/repo-test // browse repo-test

– Jgit fetch // refresh

– Jgit branch -v -a // Show all branches from S3

– Jgit checkout -b features // Switch to branch “features”


We went to step of of create, upload, clone, update local Git repository and upload to Amazon S3 service. There are more git commands we do not mention in this article we will explore in other time.