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

JGit - ssh connectivity

I am using JGit to connect to a remote Git repository. I tried below to perform same. public class Main{ public static void main(String args[]) throws Exception{ JschConfigSessionFactory sshSessionFactory = new JschConfigSessionFactory()…
shankar
  • 93
  • 2
  • 8
4
votes
3 answers

Prevent JGit from reading the native git config

I am using JGit in an app. This app has a SecurityManager in place that allows only specific white-listed classes and methods from spawning new processes. JGit internally is discovering if a native git is installed and tries to read its config in…
Yogesh_D
  • 17,656
  • 10
  • 41
  • 55
4
votes
2 answers

JGit Error-> Caused by: java.lang.NoSuchMethodError: No virtual method toPath()

I am trying clone a repository on Android Java but I get an error when I call the method toPath(). Apparently the File object has no toPath() method. public void gitClone() throws GitAPIException { // File dir = new…
user3154785
  • 121
  • 1
  • 6
4
votes
1 answer

How to hard reset from one git branch to other in JGit?

I have two branches one is master and another one level1. Now level1 is the latest I need to hard reset master to level1 normally in git bash I can do that by following command. $ git checkout master $ git tag old-master-branch $ git reset --hard…
Obuli Sundar
  • 566
  • 7
  • 26
4
votes
3 answers

List all tags in current branch with JGit

How do I list all tags in the current branch with JGit? I can list all tags easily List call = jGit.tagList().call(); for (Ref ref : call) { System.out.println("Tag: " + ref); } but how do I list only the ones that are in the current…
sydd
  • 1,824
  • 2
  • 30
  • 54
4
votes
1 answer

Cleanly shutdown JGit

I've created a local repository using JGit API's. When all processing is done, I'd like to delete the local repo (which is a simple java.io.File). However File.delete() operation fails. I'm already…
qwerty
  • 3,801
  • 2
  • 28
  • 43
4
votes
3 answers

Get message of tags using JGit

I need for each commit, to get the name and message of the associated tag. I managed to get the tag name associated with my commit . But I can't get the message. I tried like this: String nameTag = ""; List call = new…
israell
  • 173
  • 2
  • 9
4
votes
2 answers

Is partial checkout supported by JGit 3.7?

I am using Jgit 3.7 for importing files from Git repository. But I would like to import only set of folders instead of all. I know Git supports this, but I would like to know Jgit 3.7 supports the same? If so, can someone guide me.
cooltech
  • 63
  • 4
4
votes
1 answer

Creating a new local repository with JGit fails "with Bare Repository has neither a working tree..."

I am attempting to use JGit to create a local non-bare repository. I create the directory, then create a Repository object for that directory, then I use repository.create(). My research here shows that this is supposed to create a local non-bare…
Don Subert
  • 2,636
  • 4
  • 27
  • 37
4
votes
1 answer

List of files changed between commits with JGit

I'd like to get the paths of the files changed (added, modified, or deleted) between two commits. From the command line, I'd simply write git diff --name-only abc123..def456 What is the equivalent way to do this with JGit?
Paul Draper
  • 78,542
  • 46
  • 206
  • 285
4
votes
1 answer

Show changes/diffs without a parent commit (first commit) with JGit

when I do a git show commit of the first commit in a repository, I see all the files along with the diffs of the files (i.e all the lines being added) $ git show cb5d132 commit cb5d13286cf9d14782f0e10445456dfe41072f55 Author: tw2 tw2LastName…
4
votes
1 answer

How to determine with JGit which branches have been merged to master?

How do I use JGit to determine which branches have been merged to master? I want to do the equivalent of the normal git command: git branch -a --merged Is this possible in JGit?
Brian Kent
  • 3,754
  • 1
  • 26
  • 31
4
votes
1 answer

JGit: Reading commits from a submodule

I am trying to add submodules support to a project of mine, however I seem to be unable to use JGit to read specific commits or to log, while commandline git can do this just fine, despite the detached head that the submodule is in (as far as by…
centic
  • 15,565
  • 9
  • 68
  • 125
4
votes
3 answers

Get submodule hash from bare repository

We have a gitolite server with our customers custom apps. Every app has a submodule "repository/core" which refers to our base app. We would now like to create a dashboard which shows all our customers apps and at which revision there core is…
Leon Radley
  • 7,596
  • 5
  • 35
  • 54
4
votes
1 answer

Delete branch with jgit not working as expected

I am trying to delete a branch in my repo using jgit. DeleteBranchCommand command = git.branchDelete(); command.setBranchNames("myBranch"); command.setForce(true); try { List deletedBranches = new ArrayList(); deletedBranches =…
victorsc
  • 714
  • 9
  • 30