问题标签 [ngit]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
34 浏览

c# - “JGitInternalException:未给出用户名”尝试通过 SSH 克隆时从 NGit 生成的形式 Git 存储库托管在本地 TFS 上

我正在使用 NGit api 连接到 git 存储库并对其进行操作。

我有一个案例,我想连接到我在本地 TFS 上托管的 git 存储库。我创建了 ssh 密钥,将其插入到存储库中,一切顺利。但是当我想克隆存储库时,我从JGitInternalException收到一条消息说

ssh://servername:22/tfs/DefaultCollection/_git/gitrepo:未给出用户名

我假设我必须使用包含用户名的 url,就像本文定义的那样https://docs.microsoft.com/en-us/vsts/git/use-ssh-keys-to-authenticate?view=vsts

例如 ssh://username@servername:22/tfs/DefaultCollection/_git/gitrepo 左右,但是当我在浏览器中单击“克隆 repo”时,我只得到第一个 URL。

或者我应该更改 JschConfigSessionFactory 中的某些内容。任何帮助或解决方法将不胜感激。

0 投票
1 回答
287 浏览

.net - Clone a GIT repository with NGit in VB.net

My objective is to perform clone and pull operations on a GIT repository through .NET code. When cloning, I specifically want to clone a particular branch. If a particular repository is already cloned but with a different branch, then I would like to be able to know it as well.

I had implemented this with jGit in Java successfully, but now I need to develop a similar tool in .NET and I prefer using NGit since it is a direct port of jGIT library.

However, though I use the exact methods passing the relevant parameters to the clone method in NGit, I don't see repository getting downloaded. Below is my code:

When I run this, it takes few seconds and there are no errors. But in the download folder I see there is only a .git folder with some meta data and the source files are not downloaded. If I remove SetBranchesToClone and SetBranch methods from the above code, it downloads files successfully from master branch.

Why doesn't it work when branch info is provided?