Questions tagged [jgit]

JGit is an EDL (new-style BSD) licensed, lightweight, pure Java library implementing the Git version control system.

Filter by
Sorted by
Tagged with
84votes
6answers
46kviews

Confusion in choosing between JavaGit, JGit and EGit

I am making a Java application that uses Git. I found that there is something called JavaGit, EGit and JGit. I know that JavaGit and EGit/JGit are different. What I don't understand is the difference ...
user avatar
  • 17.4k
31votes
7answers
15kviews

How to "cat" a file in JGit?

A while back I was looking for an embeddable distributed version control system in Java, and I think I have found it in JGit, which is a pure Java implementation of git. However, there is not much in ...
user avatar
  • 249k
28votes
4answers
23kviews

JGit: Checkout a remote branch

I'm using JGit to checkout a remote tracking branch. Git binrepository = cloneCmd.call() CheckoutCommand checkoutCmd = binrepository.checkout(); checkoutCmd.setName( "origin/" + branchName); ...
user avatar
  • 2,618
28votes
4answers
12kviews

JGit and finding the Head

I'm trying to get my hands on the HEAD commit with JGit: val builder = new FileRepositoryBuilder() val repo = builder.setGitDir(new File("/www/test-repo")) .readEnvironment() .findGitDir() ....
user avatar
  • 92.6k
27votes
2answers
18kviews

Why is not recommended to have an Eclipse project folder as a Git repository?

When sharing a project as git and trying to make the Eclipse project folder as the git repository, Eclipse says that it is not recommended to do so and that it should be outside the Eclipse workspace. ...
user avatar
25votes
2answers
26kviews

How do I do git push with JGit?

I'm trying to build a Java application that allows users to use Git based repositories. I was able to do this from the command-line, using the following commands: git init <create some files> ...
user avatar
22votes
11answers
32kviews

Teamcity to github List remote refs failed not authorized jgit

Using github for windows on same machine, with same credentials works fine. Can pull/clone. However teamcity installed as a windows service on the same machine, returns the following error List ...
user avatar
  • 44.8k
22votes
4answers
3kviews

Is it possible to slim a .git repository without rewriting history?

We have a number of git repositories which have grown to an unmanageable size due to the historical inclusion of binary test files and java .jar files. We are just about to go through the exercise of ...
user avatar
  • 7,204
22votes
1answer
6kviews

Shallow clone with JGIT

How I can do git clone --depth 1 ... with JGIT library?
user avatar
  • 1,197
21votes
1answer
9kviews

What is the meaning of pull strategy when creating a branch with egit?

In EGit when I got to Team > Switch to > New branch I end up with the dialog box below. What is the meaning of the various pull strategies listed on this dialog box?
user avatar
  • 55.6k
20votes
3answers
15kviews

jGit - how to add all files to staging area

I tried in a lot of ways to clone a repo with jGit (it works). Then, I write some archive in the repository, and tried to add all (a git add *, git add -A or something like it).. but it don't work. ...
user avatar
  • 18.9k
19votes
3answers
7kviews

Add remote via JGit

I playing around JGit, I could successfully remove a remote from some repository (git remote rm origin), how can I do a git remote add origin http://github.com/user/repo ? To remove I do the ...
user avatar
  • 18.9k
17votes
2answers
13kviews

Use JGit TreeWalk to list files and folders

I'd like to use JGit to display a list of all files and folders for the head revision. I'm able to list all files using TreeWalk, but this does not list folders. Here is what I have so far: public ...
user avatar
17votes
2answers
3kviews

JGit how do i get the SHA1 from a RevCommit?

This seems like an idiotic question, but I can't find documentation on it anywhere. How do I get a the SHA1 of a RevCommit object?
user avatar
  • 1,707
17votes
2answers
6kviews

Egit hooks do not get triggered

I have a git repo with a pre-commit hook that intentionally fails 100% of the time. cat .git/hooks/pre-commit > exit 1 If I try to commit through the command line, it fails as expected. However, ...
user avatar
  • 7,071
16votes
2answers
11kviews

Getting all branches with JGit

How can I get all branches in a repository with JGit? Let's take an example repository. As we can see, it has 5 branches. Here I found this example: int c = 0; List<Ref> call = new Git(...
user avatar
16votes
3answers
16kviews

Using Keys with JGit to Access a Git Repository Securely

I'm using JGit to access a remote Git repo, and I need to use SSH for it. JGit uses JSch to provide secure access. However, I'm not sure how to set the key file and the knows hosts file for JGit. What ...
user avatar
  • 2,269
15votes
3answers
14kviews

IntelliJ annotate vs git blame

I am using IntelliJ's annotate feature to see in the editor who last changed a line in a file. Now I am using JGit to read the same annotations and they differ. For me it seems that Intellij checks ...
user avatar
15votes
1answer
4kviews

How to use JGit to get the URL of origin?

How to use JGit to get the URL of the origin remote? I am using JGit and I want to execute git config --get remote.origin.url How to do that?
user avatar
15votes
1answer
18kviews

Specifying SSH key for JGit

I'm wondering how I can use jgit to connect to github using a specified ssh key file (i.e. one not in ~/.ssh/). Unfortunately, I'm not sure how to use JschConfigSessionFactory properly. I've tried ...
user avatar
15votes
1answer
2kviews

JGit sets git: URI instead of https: for remote on CircleCI

I have the following code (see the comments for what's happening): // Clone repository from GitHub into a local directory. Git git = Git.cloneRepository() .setBranch("gh-pages") ...
user avatar
  • 4,572
14votes
1answer
6kviews

How do you get the author date and commit date from a JGit RevCommit?

RevCommit has a getCommitTime() method but it returns an int and it does not have an author time. How can I get the author and commit date from a RevCommit?
user avatar
  • 1,345
14votes
2answers
9kviews

How to use JGit to get list of changes in files?

Using JGit, I want to get a list of changes in files of a commits as is possible with git log --full-history -p -1 <hash-id>. Is this possible? If so, how do you do it? I know how to get each ...
user avatar
  • 3,716
13votes
6answers
20kviews

JGit: How to get all commits of a branch? (Without changes to the working directory ...)

how do I get all commits of a branch with JGit, without changing the working directory? Unfortunately the JGit docs are not very good ... In ruby with grit it is very easy: repo = Grit::Repo.new(...
user avatar
  • 440
13votes
8answers
9kviews

Egit is installed (came with Juno), but does not show at all

I want to use GIT in eclipse, and preferably EGit, for it's support from the eclipse community itself. However, despite eclipse claiming the required plugins are installed, it does not appear in the ...
user avatar
13votes
2answers
10kviews

How to get the file list for a commit with JGit

I have been working on a Java based product for which the Git features are going to be integrated. Using one of the Git features, I have done adding 10+ files into the Git repository by staging ...
user avatar
13votes
4answers
9kviews

How to merge in JGit?

How do I merge in JGit? Let's say I want to merge master with foo branch, how do I do this?
user avatar
  • 92.6k
12votes
1answer
6kviews

Check out specific revision from Git repository with JGit

I am trying to use jGit to clone a repository and checkout a particular commit. Assuming the commit hash is: 1e9ae842ca94f326215358917c620ac407323c81. My first step is: // Cloning the repository ...
user avatar
  • 4,677
12votes
4answers
15kviews

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 ...
user avatar
  • 2,269
12votes
1answer
2kviews

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 ...
user avatar
  • 543
11votes
4answers
13kviews

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 File("/...
user avatar
11votes
4answers
9kviews

Get the latest commit in a repository with JGit

I want to get the last commit metadata (the youngest one by date) in a repository using JGit. I know that I can get the commit metadata using: try (RevWalk walk = new RevWalk(repository)) { ...
user avatar
  • 2,894
11votes
1answer
5kviews

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(...
user avatar
  • 1,244
11votes
2answers
2kviews

How do I release file system locks after cloning repo via JGit

I am playing around with cloning a remote existing repo with jGit following the guide here: https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/...
user avatar
  • 3,646
11votes
4answers
3kviews

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 ...
user avatar
  • 16.2k
10votes
2answers
15kviews

UnknownHostKey Exception in Accessing GitHub Securely

I'm using jgit to access a repository in GitHub securely. I did the following to generate keys for secure communication between GitHub and my client code. Generated the key pair: ssh-keygen -t rsa ...
user avatar
  • 2,269
10votes
5answers
5kviews

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.
user avatar
  • 3,009
10votes
2answers
5kviews

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 ...
user avatar
  • 12.5k
10votes
2answers
6kviews

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.
user avatar
  • 325
10votes
3answers
4kviews

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 ...
user avatar
  • 203
10votes
1answer
3kviews

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 ...
user avatar
  • 17.2k
9votes
4answers
9kviews

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 ...
user avatar
  • 15.3k
9votes
7answers
20kviews

JGit clone repository

I'm trying to clone Git repository with JGit and I have problem with UnsupportedCredentialItem. My code: FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository = builder....
user avatar
  • 149
9votes
1answer
4kviews

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 ...
user avatar
9votes
2answers
12kviews

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/...
user avatar
  • 11.7k
9votes
3answers
10kviews

How do you set the configuration for jschconfigsessionfactory for jgit so that pull and push work?

I am trying to do a git pull/push using jgit's api with the following code org.eclipse.jgit.api.Git.open(theRepoFile).pull().call() but I am getting exceptions JSchException Auth fail com.jcraft....
user avatar
  • 4,163
9votes
1answer
5kviews

JGIT Pull NoHeadException

When is try to execute the following method (uses JGIT library) private void pullRepo() throws IOException,GitAPIException, WrongRepositoryStateException, InvalidConfigurationException, ...
user avatar
  • 1,261
9votes
2answers
3kviews

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 ...
user avatar
  • 905
9votes
3answers
4kviews

How to tune EGit for large repositories?

The problem: I find EGit great and use it intensively, but it can be incredibly slow. It can get frustrating when it takes several minutes to complete operations that the C version of git (Cgit) does ...
user avatar
  • 4,550
8votes
1answer
16kviews

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 ...
user avatar
  • 1,335

15 30 50 per page
1
2 3 4 5
19