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

How can I use JGit to add deleted files to the index?

I want to add to the index all the modifications made in a folder: files modified files added files removed File gitDir = new File("/home/franck/Repositories/Git/Sandbox/.git"); try (Repository repo = new…
FGI
  • 139
  • 2
  • 8
6
votes
1 answer

How to do a git pull with an in-memory database in JGit?

I want to create a Java program, which connects to a certain Git repository, appends text to a file, commits and pushes the changes to that repository. Ideally, all of this should happen in the memory. I'm using JGit for interaction with…
Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
6
votes
1 answer

How to count inserted/deleted lines in JGit

When we do git log --shortstat we get the number of lines inserted, deleted, and changed. Something like: 1 file changed, 9 insertions(+), 3 deletions(-) Please help me with getting the number of lines inserted, deleted, and changed. I am doing a…
SJ03
  • 61
  • 4
6
votes
2 answers

Scala version of Jgit

Looking for a stable Scala implementation (or something similar) of JGit. Has anyone worked with anything like it? I've found scala-git but it's not what I'm looking for.
YaOg
  • 1,748
  • 5
  • 24
  • 43
6
votes
1 answer

Git: Squashing consecutive commits that are not the most recent commits, and do not start at the root

I have reviewed several related questions about squashing the most recent commits and squashing a commit at the root, but neither will help me squash non-recent commits that are not at the root. Here is my starting…
modulitos
  • 14,737
  • 16
  • 67
  • 110
6
votes
1 answer

Clone git repository over ssh with username and password by Java

I am trying to clone a git project with Java over ssh. I have username and password of a git-shell user as credentials. I can clone the project in terminal using the following command with no problem. (Of course, it asks for the password first) git…
Nuri Tasdemir
  • 9,720
  • 3
  • 42
  • 67
6
votes
5 answers

Checkout conflict with files. How do I proceed?

I just pulled some changes from a remote repository holding my teams project. This is the message I received on pull: Apparently, one of my partners made changed to the same file as me. How do I proceed from here? The message is very vague. Was…
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
6
votes
1 answer

JGit list remote tags and sort by creation date

I need to list the tags of a remote Git repository and sort them by creation date via JGit 3.2.0 api. Didn't find a way with lsremote, so I have only sort by name: System.out.println("Listing remote repository " + REMOTE_URL); Collection tags =…
Rebse
  • 10,307
  • 2
  • 38
  • 66
6
votes
1 answer

What is git's advertised refs?

There is a org.eclipse.jgit.transport.OperationResult#getAdvertisedRefs in jgit. The term seems to be not specific to jgit but I can't find any precise description of the advertised refs. Best regards, Eugene.
user656449
  • 2,950
  • 2
  • 30
  • 43
6
votes
1 answer

configured http.proxy works for git but not for jgit

Lets show the --global .gitconfig first, as git and as jgit sees it!!! from a DOS window as well as from a Cgywin window E:\> git config --list --global http.auth.preference=Basic user.name=Josef…
6
votes
2 answers

JGit proxy configuration in code

I am able to clone repo using clone command in JGit Repo is http and of course it's failing to clone when I am behind proxy Could you help me with code sample how to configure JGit with proxy in java thanks!
Alan Harper
  • 793
  • 1
  • 10
  • 23
6
votes
4 answers

How to remove remote branch with JGit

I'm not able to figure out how to remove a remote branch. I was trying to mimic the following GIT command: git push origin :branchToDelete The following code and it's variations with the empty source: RefSpec refSpec = new RefSpec(); refSpec…
ivan.verhun
  • 61
  • 1
  • 4
6
votes
2 answers

jGit using RevWalk to get RevCommit returns nothing

I'm newbie on jGit and Git. I'm trying to query the historic of commit of a git repository, but I would like to get only the commit of a specific user. Reading the docs I saw that RevWalk will allow me to add RevFilters in orther to limit the…
jomaora
  • 1,656
  • 3
  • 17
  • 26
5
votes
1 answer

Git repository on S3 (as "origin", not as backup)

I recently tried the S3 remote provider of JGit, which works like a charm. EDIT: Statement regarding transmission of whole repos removed, see comments. This does not change the main question I have here, however. So now I'm thinking about using this…
theDmi
  • 17,546
  • 6
  • 71
  • 138
5
votes
2 answers

How to create a listener for Git events through the EGit/JGit plug-in?

I have been using the Subclipse API to create a plug-in for Eclipse that listens for Subversion events that happen through the Subclipse plug-in. I am basically implementing a listener interface that then gets notified during run-time about the…
jbranchaud
  • 5,909
  • 9
  • 45
  • 70