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

JGit: How to fix NoRemoteRepositoryException while creating Git Repository and pushing it to GitHub?

Using JGit, I want to create a NEW repository and push it to GitHub. I am getting NoRemoteRepositoryException. Please help. What am I missing in my code? private void createNewRepository(Task task, String path) { File directory = new File(path); …
4
votes
1 answer

Check if Git repository is private or public (e.g. for GitHub) using Java

Before we begin: I'm a newbie, so my apologies Quick description: I have a Jira plugin that can track current state of the specified repository in the selected git provider, e.g. GitHub (tracking commits, branches etc.) and display it in JIRA issue…
LexSav
  • 444
  • 1
  • 9
  • 19
4
votes
2 answers

JGit push won't fail when push is impossible

I'm trying to push a local repository to a github repository using JGit: String remote = "https://token@github.com/me/foo"; Repository repository = buildLocalRepository(); try (Git git = new Git(repository)) { git.push() …
Rad
  • 4,292
  • 8
  • 33
  • 71
4
votes
1 answer

How to pull from origin using JGit on existing repository

I need a piece of code which can pull from origin and merge with local repo. I tried with local repo which can get the last commit and revision. however not able to pull the changes from origin. File gitWorkDir = new File(gitDir); Git git =…
Deepak sethi
  • 45
  • 1
  • 5
4
votes
1 answer

how to authorize an user using jGit

I'm creating an application in Java and using jGit. As part of this I need to authenticate an user. I want to output if the user is existing or not. Currently I get an exception as user is not authorized. Below is my code. import…
user3872094
  • 3,269
  • 8
  • 33
  • 71
4
votes
1 answer

Fetching all Git branches programmatically with JGit

I am using JGit in a project and I would like to achieve the programmatic equivalent of a git --fetch all. The JGit API Documentation provides three alternative fetch operations called setRefSpecs(...). All alternatives require the developer to…
Sebastian P.
  • 818
  • 8
  • 20
4
votes
1 answer

Jgit:Bare Repository has neither a working tree, nor an index

i have created a directory in E named it gitrepo full path is (E:\gitrepo) after then i have cloned a repository in it with the following code Git git=Git.cloneRepository() .setURI("samplelink.git") .setDirectory(new…
user9452933
  • 45
  • 1
  • 5
4
votes
2 answers

JGit Java Git Library Unstaging Files

I can't get reset to work properly in JGit. Ie. i can add all files to the index, and i can remove/reset/unstage some of them from the index via the command below but it doesn't work for all files. What is the proper way to unstage files in…
Coder
  • 1,375
  • 2
  • 20
  • 45
4
votes
2 answers

get git commit SHA within Jenkins pipeline with JGit

I have a Jenkins with the Github organization plugin that scans my organization and build all the branches/PRs of all the repositories within the organization that have a Jenkinsfile. It works great, but I would like to retrieve for each build the…
gotson
  • 3,613
  • 1
  • 23
  • 40
4
votes
1 answer

How to push to gitlab with java api with ssh

I am using gitlab of version GitLab Community Edition 9.1.1 d3123f6. I am able to push my code to gitlab with http protocol but when I am trying with git protocol it is showing following error. Exception in thread "main"…
Ash
  • 149
  • 1
  • 1
  • 13
4
votes
2 answers

MissingObjectException while update submodules with JGit

I am trying to update submodules: git.submoduleUpdate().call() but I get: org.eclipse.jgit.api.errors.JGitInternalException: Missing unknown e88da827bdc5c5a4b0d87b8be79b81567759411b at…
ligi
  • 39,001
  • 44
  • 144
  • 244
4
votes
2 answers

Jenkins release issue with jgit

We are using jgit for the git project to checkout and complete the jenkins flow. It passes the snapshot build but fails for release build with the below error : Building on master in workspace…
dildeepak
  • 1,349
  • 2
  • 16
  • 34
4
votes
1 answer

Get latest committed branch(name) details in JGit

How to determine the latest committed branch in the Git repository? I want to clone only the recently updated branch instead of cloning all the branches despite of whether it is merged to master (default branch) or not. LsRemoteCommand remoteCommand…
AshokDev
  • 73
  • 9
4
votes
2 answers

Programmatically retrieve all repositories under my Github account using Jgit

I'm having a bit of a challenge with the JGit client. I'm embedding it in a Java App & I'd like to fetch all the repositories under an account on Github and display them. Also to add on, can I create a repository direct on Github using JGit. Like…
Zuko
  • 2,764
  • 30
  • 30
4
votes
1 answer

git archive remote with JGit

Can I perform a git archive from a remote repository without cloning through JGit? The idea is to improve my current clone and make it lighter by just bringing the files I need.
Nana89
  • 432
  • 4
  • 21