簡體   English   中英

如何連接到遠程倉庫?

[英]How to connect to remote repo?

我正在使用libgit2sharp,並且我有盧布連接到我的遠程倉庫。

我可以連接到本地存儲庫,但是當我嘗試使用我的存儲庫https://github.com/myProject/myRepo時出現錯誤

LibGit2Sharp.LibGit2SharpException: failed to make directory './https:': The filename, directory name, or volume label syntax is incorrect.

大概是因為我沒有使用正確的語法。 我嘗試過不帶https://和www的情況。 我只嘗試了myProject / myRepo,但它們似乎沒有用。

這是有問題的代碼。 PathToRepo是存儲庫路徑,創建存儲庫后每當我檢查存儲庫的分支時,即表示它未連接到遠程存儲庫。 該回購協議似乎沒有任何問題,但只是不與我的回購協議同步。 就是 我可以輸入一些偽造的回購路徑,它將毫無問題地創建,但無法正常工作。

 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);

只是一個猜測,但是您可能想嘗試使用.git URL。 因此,嘗試使用類似https://github.com/torvalds/linux.git而不是https://github.com/torvalds/linux

看一下您使用的LibGit2Sharp.Repository類的源代碼: https : //github.com/libgit2/libgit2sharp/blob/master/LibGit2Sharp/Repository.cs

構造函數表示String path參數指向目錄。 我看不到任何建議可用於網址,因此我懷疑您使用的構造函數僅適用於本地目錄中的本地存儲庫。

快速搜索相同的源文件后,我發現ListRemoteReferences可能會列出遠程ListRemoteReferences引用,而Clone可能會克隆遠程倉庫。 (我自己都沒有嘗試過)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM