jgit

JGit : connect to distant repository

假装没事ソ 提交于 2019-12-05 04:22:14
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. Currently, JGit 2.0.0-SNAPSHOT does only offer org.eclipse.jgit.storage.file.FileRepository org.eclipse.jgit.storage.dfs.InMemoryRepository concrete Repository classes, meaning that since org.eclipse.jgit.api.Git takes a Repository , it is not possible to work remotely. Since Git by itself is not designed to operate remotely in the way I think you mean, I doubt we will see such a feature any

IntelliJ annotate vs git blame

旧城冷巷雨未停 提交于 2019-12-05 03:36:11
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 that a line has not been changed between commits and still uses the old commit message. JGit does not see it and so makes an other message. Can anybody confirm that the behavior of JGit blame and IntelliJ differs? Whats the reason and how can I force IntelliJ to behave the same like JGit? Maybe IntelliJ ignores whitespace changes? I am using IntelliJ 15.0.1 and JGit 4.1.1 IntelliJ IDEA does not have

JGit: Retrieve tag associated with a git commit

為{幸葍}努か 提交于 2019-12-04 12:15:53
问题 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. 回答1: Git object model describes tag as an object containing information about specific object ie. commit (among other things) thus it's impossible in pure git to get information you want (commit object don't have information about related tags). This should be done "backwards", take tag object and then refer to specific commit. So if you want get

Caused by: java.lang.ClassNotFoundException: com.jcraft.jsch.JSchException

拜拜、爱过 提交于 2019-12-04 11:02:11
The protocol between local repository and remote repository is HTTPS instead of ssh,does it still need lib of jsch,and if it's true, can you tell me how to handle in details,thanks so much~~ Even if it isn't used for https access, jsch is still required for JGit. See JGit dependencies . That thread states the same thing , even when cloning an https repo. This blog post deals with a missing jsch library like so: There are 2 ways to solve this problem, depending on your setup. 1.) If you're using ant installed on your machine, example on c:\apache-ant. Just place the jsch.jar in it's lib folder.

How do I produce every possible git-status?

巧了我就是萌 提交于 2019-12-04 10:50:44
Background: We are currently using git for source management in a web app I am working on. There is an editor, and so there is also a web interface to git. One of our use cases is that people can ALSO manage their git repositories from the command line, so the web interface needs to be able to handle, in some way, any weird state it finds the repository in. Question: For testing, it would be great to get a git repository with a file in every possible state, so I could verify that all possible conditions are handled. Reading "man git-status(1)" I counted possible 24 states (not counting ignored

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

蹲街弑〆低调 提交于 2019-12-04 09:25:31
问题 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.jsch.Session.connect (Session.java:461) org.eclipse.jgit.transport.JschConfigSessionFactory.getSession (JschConfigSessionFactory.java:116) org.eclipse.jgit.transport.SshTransport.getSession (SshTransport.java:121) org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init> (TransportGitSsh

Clone git repository over ssh with username and password by Java

喜欢而已 提交于 2019-12-04 06:41:40
I am trying to clone a git project with Java over ssh. I have username and password of a git-shell user as credentials. I can clone the project in terminal using the following command with no problem. (Of course, it asks for the password first) git clone user@HOST:/path/Example.git However when I try the following code using JGIT api File localPath = new File("TempProject"); Git.cloneRepository() .setURI("ssh://HOST/path/example.git") .setDirectory(localPath) .setCredentialsProvider(new UsernamePasswordCredentialsProvider("***", "***")) .call(); I got Exception in thread "main" org.eclipse

Configuring known_hosts in jgit

偶尔善良 提交于 2019-12-04 06:36:14
Using jgit with gitolite for source control, I have an application that generates certain code on command and which we want to be committed to source control. The goal is to pull with a fast forward, commit the new code, and then push it. I have the following method: private void commitToGitRepository(String updateComment, Config config) throws IOException, NoFilepatternException, GitAPIException { if(git == null) { git = Git.open(new File(config.getDpuCheckoutDir())); } PullCommand pull = git.pull(); pull.call(); } This method fails on the pull.call() method call, with the following exception

Get a single file from a remote git repository

若如初见. 提交于 2019-12-04 03:24:42
问题 Is there a way to programmatically download a single file from a remote git repository, in Java? I prefer a solution which uses as little bandwidth as possible, preferably only downloading that single file. I do not need to browse the repository, I already have the file's path. I prefer a solution which does not depend on other applications (e.g. an installation of another git client on the machine). A Java library which contains a git client implementation itself would be optimal. I was able

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

那年仲夏 提交于 2019-12-04 02:37:01
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 order to access the Git repository where the above are committed and outputs a string which is similar to the following: int test(){ -int a = 3; -int b = 4; -int c = a + b; -return c; +return 7; } Now, my requirements have changed and would like to know the line numbers of the changed lines only. So I would want something like the following: 2 -int a = 3; 3 -int b