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

JGit - Pushing a branch and add upstream (-u option)

In JGit, I search a way to push a branch and add the upstream reference (tracking). It is the option -u or --set-upstream into the push command. I don't see a method in the class PushCommand which permits to do this. Please, could you tell me how I…
ascott
  • 552
  • 1
  • 5
  • 16
12
votes
4 answers

Usage of 'pull' command in Jgit

I'm a new user of git and am using JGit to interact with a remote git repository. In JGit, I used CloneCommand to initially to clone a repo, and it worked without a issue. However, when I try to use PullCommand, which is the equivalent of SVN update…
Izza
  • 2,389
  • 8
  • 38
  • 60
11
votes
4 answers

Is there a better database than Git (with serializable, immutable, versioned trees)?

Imagine the data structure behind Git. It's like a confluently persistent data structure, except using hash references instead of traditional pointers. I need Git's data structure, except without any of the working tree and index stuff. And there…
Lilith River
  • 16,204
  • 2
  • 44
  • 76
11
votes
4 answers

Looping over commits for a file with jGit

I've managed to get to grips with the basics of jGit file in terms of connecting to a repos and adding, commiting, and even looping of the commit messages for the files. File gitDir = new…
Andy Jarrett
  • 863
  • 2
  • 9
  • 26
11
votes
5 answers

Turn SSL verification off for JGit clone command

I am trying to a clone of a Git Repository via the CloneCommand. With this piece of code `Git.cloneRepository().setDirectory(new File(path)).setURI(url).call();` The remote repository is on a GitBlit Instance which uses self signed…
Yogesh_D
  • 17,656
  • 10
  • 41
  • 55
11
votes
1 answer

JGit Clone and get the revision hash

I am using the below code to clone a git repo from Java. I need to store the cloned latest revision hash. localRepo = new FileRepository(path); git = new Git(localRepo); Git.cloneRepository().setURI(url).setBranch("master") …
Upen
  • 1,388
  • 1
  • 22
  • 49
11
votes
1 answer

How to use JGit to push changes to remote with OAuth access token

I am able to push to remote with this piece of code return git.push().setCredentialsProvider(new UsernamePasswordCredentialsProvider(user, password)).setRemote("origin").call(); I also am able to get oauth access token with all necessary scopes.…
user1745356
  • 4,462
  • 7
  • 42
  • 70
10
votes
3 answers

JGit: Retrieve tag associated with a git commit

I want to use JGit API to retrieve the tags associated with a specific commit hash (if there is any)? Please provide code snippet for the same.
Kamal
  • 325
  • 1
  • 3
  • 9
10
votes
5 answers

Where are Jgit javadocs?

I can't find javadocs for jgit. I tried to build jgit with maven, but the build fails so I ask for your help. Where I can find javadocs for jgit.
Lukasz
  • 3,135
  • 4
  • 20
  • 24
10
votes
2 answers

How to checkout a remote branch without knowing if it exists locally in JGit?

Using ordinary git checkout the command works exactly how I would expect it to. Here are the use cases I am trying to allow for with the same piece of code: 1) git checkout branchname where branchname does not exist locally but does on remote 2) git…
MarkRobbo
  • 975
  • 1
  • 9
  • 31
10
votes
1 answer

Using native git not jgit in Eclipse git?

Is there any way to configure egit to use your native (OS) git and not the jgit implementation? If not, are there any alternative git Eclipse plugins? EDIT #1 - I should note, AWS CodeCommit uses a credential helper for auth, from…
javamonkey79
  • 17,443
  • 36
  • 114
  • 172
10
votes
2 answers

How to show changes between commits with JGit

I am trying to show a git diff between two commits for a file. Basically, I did it as in https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ShowChangedFilesBetweenCommits.java You can see my full code…
svenhornberg
  • 14,376
  • 9
  • 40
  • 56
10
votes
2 answers

How to obtain the RevCommit or ObjectId from a SHA1 ID string with JGit?

This question is the inverse of this question: JGit how do i get the SHA1 from a RevCommit?. If I am given the SHA1 ID of a particular commit as a string, how can I obtain the ObjectId or associated RevCommit in JGit? Here is a possible answer,…
modulitos
  • 14,737
  • 16
  • 67
  • 110
10
votes
1 answer

JGit Check if a branch is checked out

I am working on a project using JGit. I managed to delete a branch, but I also want to check if that branch is checked out or not. I found a variable in CheckoutCommand but it is private: private boolean isCheckoutIndex() { return startCommit ==…
marius9228
  • 113
  • 1
  • 7
10
votes
3 answers

Using the JGIT, how can I retrieve the line numbers of added/deleted lines

Assuming the following piece of code is committed to a Git repository: int test(){ int a = 3; int b = 4; int c = a + b; return c; } and is later updated to int test(){ return 7; } I currently have a method which uses the JGit API in…
gracey
  • 213
  • 3
  • 14
1 2
3
63 64