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

Authentification with JGit 's PullCommand

I am using JGit and want to pull from the remote repository to my local repository. The first approch was to clone the repository and that worked fine: CredentialsProvider cp = new UsernamePasswordCredentialsProvider(username, password); try (Git…
Hauke
  • 1,405
  • 5
  • 23
  • 44
8
votes
1 answer

JGit create new local branch and push to remote (branch does not exist on remote)

I'm working on an ANT task that calls some java that uses JGit to create a new branch on a git repository and push it to remote. I'm using JGit 2.1.0. Here's the code: CreateBranchCommand bcc; CheckoutCommand checkout; Git git; try { Repository…
ptha
  • 836
  • 1
  • 8
  • 22
8
votes
1 answer

How do I get the tree from parent commits using the JGit API?

For a given commit I want to get the parent(s) commit tree so I can go on to compare the changes. I am finding that getTree() on the parent RevCommit objects always returns null. ObjectId lastCommitId = repository.resolve(Constants.HEAD); …
Interition
  • 381
  • 2
  • 15
8
votes
2 answers

List commits associated with a given tag with JGit

I need to create a history file that details all tags and for each tag, all its commits. I've tried to call getTags() on the repository object and use those object id's, but they are not commit id's. I also tried to use getAllRefsByPeeledObjectId()…
YaOg
  • 1,748
  • 5
  • 24
  • 43
8
votes
1 answer

Does JGit support Git Credentials?

Does JGit support Git Credentials as documented here: http://git-scm.com/docs/gitcredentials? I haven't found yet anything to this topic.
olibur
  • 337
  • 5
  • 13
8
votes
2 answers

List branches of a git remote repo without cloning it

I was wondering hows it would be possible to list all the branches of a remote Git repo with jgit but without cloning it. While going through the jgit's javadoc, I found the ListBranchCommand but that only seem to work with an already opened…
Augier
  • 352
  • 4
  • 14
8
votes
3 answers

How to Check if A Git Clone Has Been Done Already with JGit

I learning git and using JGit to access Git repos from java code. Git by default does not allow to clone to a non-empty directory. How do we figure out that a git clone has already been done for a particular git repo in the local machine so that we…
Izza
  • 2,389
  • 8
  • 38
  • 60
8
votes
7 answers

JGIT validate if repository is valid

Is there a method to kill a clone operation mid-stream? I will just use the cloning to validate the repository? Is there any other way to test if the remote url/repository is valid?
code-red
  • 306
  • 3
  • 12
8
votes
3 answers

JGit : How to get Branch when traversing repos

The lacking JGit docs dont seem to say anything about how to use/detect branches while using a RevWalk. This question says pretty much the same thing. So my question is: How do I get the branch name/id from a RevCommit? Or how do I specify which…
Braden
  • 1,548
  • 2
  • 12
  • 20
8
votes
2 answers

JGit : connect to distant repository

I searched through Google, forums and JGit user guide but couldn't find how to connect to a distant repository with the API. Anyone has an example or just an idea on how to do that? Thanks for your help.
Brice
  • 81
  • 1
  • 2
8
votes
3 answers

Commit a String with JGit

A JGit-beginner-question: I use JGit to read a file (BLOB) from a repository and manipulate its content. After that, I want to write the new content with the same filename back to the repository as a new commit. But how can I commit the new content…
Sonson123
  • 10,879
  • 12
  • 54
  • 72
7
votes
4 answers

How to write or package a Git server as a Java Servlet or Java webapp?

Git is clearly awesome and a variety of clients are both available and easy to install for all platforms. However it's a bit of a challenge to get a Git server up and running for teams. I'm a bit surprised that there is not yet an easily…
Brendan
  • 408
  • 7
  • 8
7
votes
1 answer

JGit - How to reuse the DiffFormatter

It's a followup question of jgit - git diff based on file extension. I am trying to add the formatted diff to List but If I try to use same DiffFormatter as below then previous entries getting appended to the next one. List changes…
nantitv
  • 3,539
  • 4
  • 38
  • 61
7
votes
1 answer

jgit - git diff based on file extension

I am using JGit API (https://www.eclipse.org/jgit/) to access a git repository. In the git repository, I am storing .txt files and other file formats also. I ran into a requirement where I should get the diff of only .txt files. Basically I am…
nantitv
  • 3,539
  • 4
  • 38
  • 61
7
votes
2 answers

How to find the branch for a commit with JGit?

I need to obtain the name of the branch that is associated with a specific commit using JGit. I used JGit to obtain the complete list of commit SHA's for a repository and now I need to know the name of the branch it belongs to. Appreciate if someone…
Tony P
  • 211
  • 5
  • 12