Questions tagged [jgit]

JGit is an EDL (new-style BSD) licensed, lightweight, pure Java library implementing the Git version control system.

JGit is an EDL (new-style BSD) licensed, lightweight, pure Java library implementing the version control system.

It is developed as part of the Eclipse Git Plugin .

JGit Supports:

  • Repository access routines
  • Network protocols
  • Core version control algorithms
  • Implementation of many porcelain commands
  • tasks for performing Git operations as part of automated builds
  • A Git daemon to provide a simple Git server
  • A jgit commandline tool for working with Git repositories

For details visit the Project page or the User Guide, there is also API Documentation available.

The community-provided jgit-cookbook provides ready-to-run snippets that show how things can be achieved when using JGit

956 questions
10
votes
2 answers

UnknownHostKey Exception in Accessing GitHub Securely

I'm using jgit to access a repository in GitHub securely. I did the following to generate keys for secure communication between GitHub and my client code. Generated the key pair: ssh-keygen -t rsa Added the public key to GitHub account with…
Izza
  • 2,389
  • 8
  • 38
  • 60
9
votes
7 answers

JGit clone repository

I'm trying to clone Git repository with JGit and I have problem with UnsupportedCredentialItem. My code: FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository =…
Scruger
  • 149
  • 1
  • 1
  • 3
9
votes
3 answers

JGit checkout vs `git checkout` problems

tl;dr JGit's checkout throws exceptions while command line git checkout works fine I'm currently trying to use JGit to check out certain revisions from an online Git repository, in Java (for work). My current approach is (and I'm very new to Git,…
Dylan
  • 13,645
  • 3
  • 40
  • 67
9
votes
3 answers

Jgit throws java.io.IOException: Creating directories for /.config/jgit failed

Recently upgraded Jgit to 5.10.0.202012080955-r. After this, we are getting IOException after clone of a bare git repository. It doesn't seem to cause any visible functional impact so far, but its a cause of concern. This issue is seen only in…
Omkar Shetkar
  • 3,488
  • 5
  • 35
  • 50
9
votes
4 answers

Do GitHub and GitLab support git clone's --filter parameter?

I want to use git's partialClone feature. In this answer I saw the git clone --filter=tree:none command. But when trying to execute on github, the prompt warning: filtering not recognized by server, ignoring. It did not work. I want to know…
Ph0rse
  • 93
  • 6
9
votes
3 answers

Clone a git repository into an InMemoryRepository with JGit

I need to clone an existing git repository into an InMemoryRepository, using JGit, change a file's content and push the changes back to the remote repository. I couldn't find any examples of cloning a repository into an in-memory repository. I…
arikabc
  • 675
  • 1
  • 6
  • 11
9
votes
4 answers

How is a merge-base done in JGit?

I'm looking at the JGit Documentation, currently at version 3.5.1.201410131835-r, and I cannot find the equivalent of git-merge-base. I would like to determine if a branch is up-to-date, behind, ahead, or diverged, as shown in git: check if pull…
Ed I
  • 7,008
  • 3
  • 41
  • 50
9
votes
3 answers

How to tune EGit for large repositories?

The problem: I find EGit great and use it intensively, but it can be incredibly slow. It can get frustrating when it takes several minutes to complete operations that the C version of git (Cgit) does in less than a couple of seconds. All operations…
PeterSW
  • 4,921
  • 1
  • 24
  • 35
9
votes
1 answer

JGIT Pull NoHeadException

When is try to execute the following method (uses JGIT library) private void pullRepo() throws IOException,GitAPIException, WrongRepositoryStateException, InvalidConfigurationException, DetachedHeadException, InvalidRemoteException,…
Bgvv1983
  • 1,256
  • 1
  • 13
  • 27
9
votes
3 answers

How do you set the configuration for jschconfigsessionfactory for jgit so that pull and push work?

I am trying to do a git pull/push using jgit's api with the following code org.eclipse.jgit.api.Git.open(theRepoFile).pull().call() but I am getting exceptions JSchException Auth fail com.jcraft.jsch.Session.connect…
bmillare
  • 4,183
  • 2
  • 23
  • 42
8
votes
1 answer

How do I do the equivalent of "git diff --name-status" with jgit?

I want to get a list of changed/added/deleted files between revision XXXXXX and HEAD. This is what I have so far: String oldHash = "a97e5553e37a25bd1a3c99eab303145baed08dbd"; Git git = Git.open(new File("/tmp/jgit")); Repository repository =…
Erik
  • 274
  • 4
  • 13
8
votes
1 answer

Java git client using jgit

I am having some difficulties with a git client written in java. I am using the jGit library to connect through ssh on the git server. The problem is that i don't know how to specify the path to the private key and the passphrase for it. I couldn't…
azertys
  • 132
  • 1
  • 8
8
votes
1 answer

Add a file inside a folder to Github using JGit or EGit - directory1\myfile.txt

*Added final working program to the bottom of this question * I was able to add a file to GitHub using org.eclipse.egit.github.core java library (and code sample is referred from here: https://gist.github.com/Detelca/2337731 ) But I am not able to…
Gana
  • 482
  • 3
  • 11
  • 32
8
votes
2 answers

Java (JGIT) Files.delete() fails to delete a file, but file.delete() succeeds

I'm cloning a git repo into a temp directory using jgit (version 4.8.0.201706111038-r) and adding a shutdown hook to delete the temp directory after termination. However, the shutdown hook fails to delete some files from within the .git subdirectory…
Malt
  • 28,965
  • 9
  • 65
  • 105
8
votes
3 answers

Get a single file from a remote git repository

Is there a way to programmatically download a single file from a remote git repository, in Java? I prefer a solution which uses as little bandwidth as possible, preferably only downloading that single file. I do not need to browse the repository, I…
Oak
  • 26,231
  • 8
  • 93
  • 152