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
5
votes
2 answers

Retrieving Commit Message Log from Git Using JGit

I just want to retrieve the commitlog from Git repository that has messages for all the commit you've done on a specific repopsitory. I had found some code snippets for achieve this and ends with an exception. try { FileRepositoryBuilder builder…
Varun Kumar
  • 1,015
  • 2
  • 9
  • 17
5
votes
2 answers

How to open a repository creating it if it does not exist in JGit?

Came up with: /** * Create a repo at the specified directory or open one if it already * exists. Return a {@link Git} object... * * @param p * Path to the repo root (the dir that contains the .git folder) * @return a "Git" object to…
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
5
votes
2 answers

Determine number of commit ahead and behind using JGit

On a GitHub project, when we go to any branches page, we can see graphs which describes commit ahead/behind numbers of a branch w.r.t. master. How can we determine those ahead behind numbers using JGit? I used BranchTrackingStatus class for this,…
Gaurav Chaudhary
  • 483
  • 1
  • 6
  • 12
5
votes
3 answers

How do I produce every possible git-status?

Background: We are currently using git for source management in a web app I am working on. There is an editor, and so there is also a web interface to git. One of our use cases is that people can ALSO manage their git repositories from the command…
mtoy
  • 583
  • 1
  • 5
  • 13
5
votes
2 answers

eclipse: "re-indexing repository workspace" or "Computing Git status for repository workspace"

I am using eclipse Juno, and yesterday I noticed my computer was getting very hot. I checked the CPU usage to see it was at 100%. Eclipse was the culprit, busy "re-indexing repository workspace". When after half an hour it hadn't finished and my…
mdarwin
  • 1,684
  • 7
  • 28
  • 72
5
votes
1 answer

How to use JGit to get list of changed files?

Using JGit, I want to get a list of files changed on commits as is possible with git log --name-status. Is this possible? If so, how do you do it?
Supersouth
  • 79
  • 1
  • 3
5
votes
2 answers

How to diff with two files by JGit without creating repo?

When I use JGit to diff with two files, I must create a repo first. But in Git, I only need to use command git diff --no-index 1.txt 2.txt. Is there a way to use diff in JGit without creating repo?
eabiao
  • 99
  • 1
  • 4
5
votes
3 answers

JGit branch checkout Issue

I am checking out a repository from github using the following code . private String url = "https://github.com/organization/project.git"; Git repo = Git.cloneRepository().setURI(url).setDirectory(directory).setCloneAllBranches(true).call(); …
Muthu
  • 1,550
  • 10
  • 36
  • 62
5
votes
1 answer

Getting commit information from a RevCommit object in JGit

I called the jgit log command and got back some RevCommit objects. I can get back some basic information from it and I use the following code to get the list of files that changed. There are two more things that I need though: 1) how do I get the…
Coder
  • 1,375
  • 2
  • 20
  • 45
5
votes
3 answers

How to "git log --follow " in JGit? (To retrieve the full history including renames)

How do I have to extend the following logCommand, to get the --follow option of the git log command working? Git git = new Git(myRepository); Iterable log = git.log().addPath("com/mycompany/myclass.java").call(); This option is…
OneWorld
  • 17,512
  • 21
  • 86
  • 136
5
votes
1 answer

Git fetch failing using jgit: Remote does not have available for fetch

I have a bare repo located at main.git and am trying to fetch a branch (foo, let's say) in another repo, test, which has only just been git init'd: fetchtest/ |- main.git/ |- test/ |- .git/ Using regular git commands, I can do a git…
Callum Rogers
  • 15,630
  • 17
  • 67
  • 90
4
votes
1 answer

JGit: Count objects

How can I retrieve the total number of git objects in a repository? (I search something like the git count-objects in JGit.) I made a Java program that calculates statistic values and has to read every object (blob, tree, commit, tag) of a git…
Sonson
  • 1,129
  • 1
  • 11
  • 14
4
votes
2 answers

How can I find the first commit of a branch with JGit?

I want to find the first commit for a specific branch, using Eclipse's JGit library. For example if I have master -- a -- c -- d -- e \ feature b -- f -- g -- h \ another j -- k -- l // findBranchRoot() is the magic…
TheCrafter
  • 1,909
  • 2
  • 23
  • 44
4
votes
0 answers

JGit: GPG to commit files without passing passphrase nor using console input?

I am trying to use gpg to commit to git, I have my username and token already being used and it works without any passphrase using ssh but not for gpg! I am coming across below error org.bouncycastle.openpgp.PGPException: missing credentials…
4
votes
0 answers

Gradle source dependencies with private git repository

I trying to use the recently added support source dependencies as described by: https://blog.gradle.org/introducing-source-dependencies My problem is that I would like to use a private repo, so my question is how can I pass the authentication…
Luis Trigueiros
  • 636
  • 7
  • 21