jgit

How to Check if A Git Clone Has Been Done Already with JGit

白昼怎懂夜的黑 提交于 2019-12-22 10:58:43
问题 I learning git and using JGit to access Git repos from java code. Git by default does not allow to clone to a non-empty directory. How do we figure out that a git clone has already been done for a particular git repo in the local machine so that we can only do a Git pull subsequently? Currently I'm using this approach: if a root folder is existing in the specified location clone has been done pull else clone Not sure if this is correct though. Any better ideas? Thank you. 回答1: This is the

How to set tracking on an existing repo to a remote repo with ngit (or jgit)?

蓝咒 提交于 2019-12-22 06:38:14
问题 I am working on a gui based helper utility that will: Init a local repo, Init (bare) a remote repo Add .gitignore based on a project type Commit all the files locally Add a remote repo to the local config Push master to the remote repo Create a develop branch and push it to master All this is done without git installed by using ngit (.NET port of jgit). But I can't figure out how to setup tracking to track master to origin/master and develop to origin/develop using just ngit . I can do it

IntelliJ annotate vs git blame

随声附和 提交于 2019-12-22 04:01:44
问题 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

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

有些话、适合烂在心里 提交于 2019-12-21 17:43:17
问题 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~~ 回答1: 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

Clone git repository over ssh with username and password by Java

时光怂恿深爱的人放手 提交于 2019-12-21 13:43:12
问题 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

Clone git repository over ssh with username and password by Java

你离开我真会死。 提交于 2019-12-21 13:43:08
问题 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

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

ぃ、小莉子 提交于 2019-12-21 09:17:18
问题 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

Java git client using jgit

偶尔善良 提交于 2019-12-20 20:41:31
问题 I am having some difficulties with a git client written in java. I am using the jGit library to connect through ssh on the git server. The problem is that i don't know how to specify the path to the private key and the passphrase for it. I couldn't find any examples in the jGit documentation about what functions i need to call. From what i read the jGit library is using JSch to connect to the server using ssh and JSch supports private keys and passphrases. Does anyone have any experience with

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

非 Y 不嫁゛ 提交于 2019-12-20 19:43:27
问题 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 would be millions of branches, each tracking a handful of other local branches. Commits and merges would occur several thousand times per minute on different threads. Pulls would occur every second. Between libgit2 and jgit I can use Git's data

How to show history with remote git repository only in JGit

感情迁移 提交于 2019-12-20 07:59:21
问题 I only want to run the git log command to get some commit info, and don't want to do it after cloning a remote reprository to local. Wonder if there is quick way for JGit here? 回答1: All operations on a Git repository are local. In order to access the history of a repository, you must clone it first. If you are only interested in the current state you may do a shallow clone to save some bandwidth. 来源: https://stackoverflow.com/questions/48760586/how-to-show-history-with-remote-git-repository