[英]How to connect to remote repo?
I'm using libgit2sharp and i'm having rouble connecting to my remote repo. 我正在使用libgit2sharp,并且我有卢布连接到我的远程仓库。
I can connect to a local repo but when i try to use my repo https://github.com/myProject/myRepo i get an error 我可以连接到本地存储库,但是当我尝试使用我的存储库https://github.com/myProject/myRepo时出现错误
LibGit2Sharp.LibGit2SharpException: failed to make directory './https:': The filename, directory name, or volume label syntax is incorrect.
Presumably this is because i'm not using the correct syntax. 大概是因为我没有使用正确的语法。 I've tried without https://, with www.
我尝试过不带https://和www的情况。 i've tried just myProject/myRepo but they don't seem to work.
我只尝试了myProject / myRepo,但它们似乎没有用。
Here is the code in question. 这是有问题的代码。 PathToRepo is the repo path and whenever i check the branches of my repo after it is created i ee that it is not connecting to the remote repo.
PathToRepo是存储库路径,创建存储库后每当我检查存储库的分支时,即表示它未连接到远程存储库。 The repo seems to create with no issues but it just doesn't sync to my repo.
该回购协议似乎没有任何问题,但只是不与我的回购协议同步。 Ie.
就是 i could put in some bogus repo path and it will create with no problem but just not work.
我可以输入一些伪造的回购路径,它将毫无问题地创建,但无法正常工作。
if (!Repository.IsValid(PathToRepo))
{
Repository.Init(PathToRepo);
}
repo = new Repository((PathToRepo));
var brnch = repo.Branches.Where(x => x.FriendlyName == Branch).FirstOrDefault();
if (brnch == null)
{
brnch = repo.CreateBranch(Branch);
}
Commands.Checkout(repo, brnch);
Just a guess, but you might want to try using the .git URL instead. 只是一个猜测,但是您可能想尝试使用.git URL。 So try something like
https://github.com/torvalds/linux.git
instead of https://github.com/torvalds/linux
因此,尝试使用类似
https://github.com/torvalds/linux.git
而不是https://github.com/torvalds/linux
Have a look at the source of LibGit2Sharp.Repository
class that you are using: https://github.com/libgit2/libgit2sharp/blob/master/LibGit2Sharp/Repository.cs 看一下您使用的
LibGit2Sharp.Repository
类的源代码: https : //github.com/libgit2/libgit2sharp/blob/master/LibGit2Sharp/Repository.cs
The constructor says the String path
parameter is to a directory. 构造函数表示
String path
参数指向目录。 I don't see any suggestion that this works with a web address, so I suspect that the constructor you are using only works with local repositories in a local directory. 我看不到任何建议可用于网址,因此我怀疑您使用的构造函数仅适用于本地目录中的本地存储库。
After a quick search through that same source file, I found ListRemoteReferences
which might list references for your remote repo, and Clone
which will likely clone a remote repo. 快速搜索相同的源文件后,我发现
ListRemoteReferences
可能会列出远程ListRemoteReferences
引用,而Clone
可能会克隆远程仓库。 (I haven't tried either of these myself). (我自己都没有尝试过)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.