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
17
votes
1 answer

Specifying SSH key for JGit

I'm wondering how I can use jgit to connect to github using a specified ssh key file (i.e. one not in ~/.ssh/). Unfortunately, I'm not sure how to use JschConfigSessionFactory properly. I've tried creating a setup just like the one in this article:…
nstbayless
  • 175
  • 1
  • 1
  • 7
17
votes
2 answers

Use JGit TreeWalk to list files and folders

I'd like to use JGit to display a list of all files and folders for the head revision. I'm able to list all files using TreeWalk, but this does not list folders. Here is what I have so far: public class MainClass { public static void…
Gaurav Sharma
  • 4,032
  • 14
  • 46
  • 72
17
votes
3 answers

Using Keys with JGit to Access a Git Repository Securely

I'm using JGit to access a remote Git repo, and I need to use SSH for it. JGit uses JSch to provide secure access. However, I'm not sure how to set the key file and the knows hosts file for JGit. What I have tried is as follows. Created a custom…
Izza
  • 2,389
  • 8
  • 38
  • 60
16
votes
3 answers

IntelliJ annotate vs git blame

I am using IntelliJ's annotate feature to see in the editor who last changed a line in a file. Now I am using JGit to read the same annotations and they differ. For me it seems that Intellij checks that a line has not been changed between commits…
16
votes
2 answers

Getting all branches with JGit

How can I get all branches in a repository with JGit? Let's take an example repository. As we can see, it has 5 branches. Here I found this example: int c = 0; List call = new Git(repository).branchList().call(); for (Ref ref : call) { …
Evgenij Reznik
  • 17,916
  • 39
  • 104
  • 181
15
votes
1 answer

JGit sets git: URI instead of https: for remote on CircleCI

I have the following code (see the comments for what's happening): // Clone repository from GitHub into a local directory. Git git = Git.cloneRepository() .setBranch("gh-pages") …
randers
  • 5,031
  • 5
  • 37
  • 64
14
votes
2 answers

How to use JGit to get list of changes in files?

Using JGit, I want to get a list of changes in files of a commits as is possible with git log --full-history -p -1 . Is this possible? If so, how do you do it? I know how to get each commit, and look at the commit message: //Load…
Whitecat
  • 3,882
  • 7
  • 48
  • 78
14
votes
1 answer

Check out specific revision from Git repository with JGit

I am trying to use jGit to clone a repository and checkout a particular commit. Assuming the commit hash is: 1e9ae842ca94f326215358917c620ac407323c81. My first step is: // Cloning the repository Git.cloneRepository() .setURI(remotePath) …
MrD
  • 4,986
  • 11
  • 48
  • 90
14
votes
6 answers

JGit: How to get all commits of a branch? (Without changes to the working directory ...)

how do I get all commits of a branch with JGit, without changing the working directory? Unfortunately the JGit docs are not very good ... In ruby with grit it is very easy: repo = Grit::Repo.new(pathToRepo) repo.commits(branchName, false).each do…
hurik
  • 450
  • 1
  • 3
  • 15
14
votes
1 answer

How do you get the author date and commit date from a JGit RevCommit?

RevCommit has a getCommitTime() method but it returns an int and it does not have an author time. How can I get the author and commit date from a RevCommit?
Coder
  • 1,375
  • 2
  • 20
  • 45
14
votes
4 answers

How to merge in JGit?

How do I merge in JGit? Let's say I want to merge master with foo branch, how do I do this?
Tower
  • 98,741
  • 129
  • 357
  • 507
13
votes
3 answers

How to get the file list for a commit with JGit

I have been working on a Java based product for which the Git features are going to be integrated. Using one of the Git features, I have done adding 10+ files into the Git repository by staging followed by committing them in a single commit. Is the…
Thamilarasan M
  • 171
  • 1
  • 1
  • 8
13
votes
8 answers

Egit is installed (came with Juno), but does not show at all

I want to use GIT in eclipse, and preferably EGit, for it's support from the eclipse community itself. However, despite eclipse claiming the required plugins are installed, it does not appear in the perspectives, import and settings menu's. I am…
Mark Tielemans
  • 1,528
  • 3
  • 20
  • 40
12
votes
4 answers

Get the latest commit in a repository with JGit

I want to get the last commit metadata (the youngest one by date) in a repository using JGit. I know that I can get the commit metadata using: try (RevWalk walk = new RevWalk(repository)) { RevCommit commit =…
Master Mind
  • 3,014
  • 4
  • 32
  • 63
12
votes
2 answers

How do I release file system locks after cloning repo via JGit

I am playing around with cloning a remote existing repo with jGit following the guide here: https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CloneRemoteRepository.java I'm using CFML for my example: Git…
Brad Wood
  • 3,863
  • 16
  • 23
1
2
3
63 64