Reading:
Private Git Server Repository on AWS S3 Bucket

Private Git Server Repository on AWS S3 Bucket

Metamug
Private Git Server Repository on AWS S3 Bucket

Prerequisites

  • Account with AWS S3
  • Java Installed on the client machine where git needs to be setup.
  • Knowlege of git commands and aws s3

AWS S3 Bucket

Create a AWS S3 bucket as per domain name. git.mycompany.com

IAM credentials for AWS S3 Access

Create Users in AWS IAM and give them AWS S3 Full Access. Download the credentials for the user in csv. Use these credentials to create the .jgit file later. This will be used to access the s3 repos. You don't need to provide public access to S3 bucket. As these keys can access the s3 bucket containing your repositories in the private mode.

Download JGit

Now download jgit.sh from eclipse site. After download change its name to jgit.sh

Download JGit

Windows Setup

Place the jgit.sh file in your user folder C:\Users\myaccount. Create a bat file jgit.bat in the same directory with following

java -jar C:\Users\myaccount\jgit.sh %*

Now create a .jgit file and keep it same folder.

accesskey:AK***************
secretkey:A1***************************
acl: private

So at the end of it We have following 3 files in User Directory

  • jgit.sh
  • jgit.bat
  • .jgit

Now add C:\Users\myaccount to Path Environment Variable.

Linux

For linux you do not need the jgit.bat file. Keep the 2 files in /home/myaccount

sudo ln /home/myaccount/jgit.sh /usr/bin/jgit
chmod +x /usr/bin/jgit

Make sure you have java installed on linux

Run JGit

JGit is same as Git. All the commands that work with git cli work with jgit

jgit --version

Create a git repo

jgit init
jgit add .
jgit remote add origin amazon-s3://.jgit@git.mycompany.com/project/example-project.git
jgit commit -m "initial commit"
jgit push

You can clone the same repo with

jgit clone amazon-s3://.jgit@git.mycompany.com/project/example-project.git

JGit Fetch and merge

jgit pull

The above command will work not work with jgit. You need to use fetch and merge.

jgit fetch
jgit merge

Happy Coding!!!



Icon For Arrow-up
Comments

Post a comment