-1

I have been trying to find a way to git to the AWS S3 bucket. While searching, I found this blog: https://fancybeans.com/2012/08/24/how-to-use-s3-as-a-private-git-repository/.

As per the blog says:

  1. I have created S3 bucket (test-git-repo) and a folder inside (testing) and an IAM user with S3 bucket access

  2. I have downloaded jgit-3.7.1 in my `/bin´ folder renamed as git.

  3. created a .git_s3_public file and added both access keys saved in /home/ubuntu with 600 permission

  4. in /home/ubuntu/ I have created a directory s3-git and added some files with

    git init
    git add *
    git commit -m "my new files yay!"
    git remote add s3 amazon-s3://.jgit_s3_public@test-git-repo/tesing/s3-git
    jgit push s3 refs/heads/master
    

When I'm doing jgit push I'm getting the below error:

java.lang.IllegalStateException: Cannot set value to a final field 'org.eclipse.jgit.pgm.Push.refSpecs'.
at org.kohsuke.args4j.spi.Setters.create(Setters.java:32)
at org.kohsuke.args4j.ClassParser.parse(ClassParser.java:38)
at org.kohsuke.args4j.CmdLineParser.<init>(CmdLineParser.java:96)
at org.kohsuke.args4j.CmdLineParser.<init>(CmdLineParser.java:71)
at org.eclipse.jgit.pgm.opt.CmdLineParser.<init>(CmdLineParser.java:119)
at org.eclipse.jgit.pgm.opt.CmdLineParser.<init>(CmdLineParser.java:102)
at org.eclipse.jgit.pgm.TextBuiltin.parseArguments(TextBuiltin.java:224)
at org.eclipse.jgit.pgm.TextBuiltin.execute(TextBuiltin.java:208)
at org.eclipse.jgit.pgm.Main.execute(Main.java:223)
at org.eclipse.jgit.pgm.Main.run(Main.java:124)
at org.eclipse.jgit.pgm.Main.main(Main.java:98)

I have downloaded the .jar files for slf4j-jdk14.jar, slf4j-simple.jar, slf4j-api.jar of version 1.7.5 and put them in /bin/ folder.

Still I'm getting the same error. I have tried a simple command

jgit config

still the same error

Can anybody help me out here to solve this issue or any other way to git to S3.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
Harry Kris
  • 61
  • 2
  • 12
  • 1
    This looks like an issue specific to jgit rather than S3 and AWS. I suggest you register on the jgit project forums and check whether this is a known issue. – mcfinnigan Feb 13 '18 at 12:53
  • I see you are new to SO. If you feel an answer solved the problem, please mark it as 'accepted' by clicking the green check mark. This helps keep the focus on older posts which still don't have answers. – Rüdiger Herrmann Feb 15 '18 at 13:45

2 Answers2

3

This is not exactly a solution to your problem but its a workaround. You may configure a git server into an EC2 for example and then use S3FS (https://github.com/s3fs-fuse/s3fs-fuse) to mount the git servers data directory in S3. In that way, all your data will be stored in S3 without use jgit.

2

The exception is not related to pushing to S3. The JGit command line utility fails while using reflection to apply the command line arguments to the JGit API.

This bug has been fixed with commit a0558b709448cea01cc0725fff73408d9b223c72 - Remove final modifier on args4j option or argument fields

Note that this bug only affects JGit's command line utility pgm. Pushing changes programmatically through the PushCommand API is not affected.

Use a recent version of JGit, e.g. 4.10 to overcome the problem.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79