Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6599771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:32:02+00:00 2026-05-25T18:32:02+00:00

tl;dr JGit’s checkout throws exceptions while command line git checkout works fine I’m currently

  • 0

tl;dr JGit’s checkout throws exceptions while command line git checkout works fine

I’m currently trying to use JGit to check out certain revisions from an online Git repository, in Java (for work). My current approach is (and I’m very new to Git, coming from a SVN background, so this may be wrong):

  • clone the repository to a temporary location on my hard drive
  • figure out which revision I want, (I have tried using the SHA-1 hash as well as the name of a branch)
  • checkout that revision
  • from there, I would be using the checked out files as inputs to a later part of the program.
  • checkout a different revision
  • use those files as inputs to another part of the program

Essentially, I want to be able to swap the contents of my temp folder with whichever revision. With the command line interface I’ve been able to do this with git checkout master and git checkout dylanbranch (where dylanbranch is a branch I made on my own clone with an arbitrarily chosen revision), but my Java code attempting to do the same thing fails:

Git git = Git.open(new File("checkout")); //checkout is the folder with .git
git.checkout().setName("master").call(); //succeeds
git.checkout().setName("dylanbranch").call(); //fails

And the exceptions printed to the console:

Exception in thread "main" org.eclipse.jgit.api.errors.JGitInternalException: Checkout conflict with files: 
src/sizzle
test/qunit
    at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:211)
    at com.avi.scm.git.BranchCheckout.main(BranchCheckout.java:30)
Caused by: org.eclipse.jgit.errors.CheckoutConflictException: Checkout conflict with files: 
src/sizzle
test/qunit
    at org.eclipse.jgit.dircache.DirCacheCheckout.checkout(DirCacheCheckout.java:387)
    at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:162)
    ... 1 more

I can verify that the files in question are marked as deleted and not staged for commit by using git status though I’m not sure why those changes are there, and they come back any time I switch back to the master branch. Despite that, I can still successfully change the working tree with command line Git.

So my question: Why won’t JGit work for this application when command line git will?
Any other helpful information is appreciated- educate me 🙂

Update I’ve been testing with the jQuery repository, and have noticed a few more problems with JGit: When I am working with the “master” branch, git status temms me that I’m #On branch master and that there is nothing to commit (working directory clean), but using JGit’s status command I see that test/qunit and src/sizzle are marked as Missing. JGit’s reset seems to do nothing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:32:03+00:00Added an answer on May 25, 2026 at 6:32 pm

    The two directories mentioned in the stack trace are Git submodules (test/qunit and src/sizzle) which is most likely the cause of the problem since JGit does not have full submodule support yet.

    This may function differently in the 1.1 JGit release due out this month based on this commit.

    You can read more about the current state of JGit submodule support here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A while back I was looking for an embeddable distributed version control system in
Trying to setup replication from gerrit to my github repo. Getting this stacktrace: [2011-09-20
I seem to have managed to have a commit with two duplicate parents using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.