gpt4 book ai didi

libgit2sharp - 在 libgit2sharp 中更改存储库的远程 url

转载 作者:行者123 更新时间:2023-12-04 04:45:14 25 4
gpt4 key购买 nike

我们如何更改存储库的远程 url?

using (var repository = new Repository(repositoryPath))
{
//Change the remote url first
//Then checkout
}

最佳答案

How can we change the remote url of a repository?

var newUrl = "https://github.com/owner/my_repository.git";";

Remote remote = repo.Network.Remotes[name];

// This will update the remote configuration, persist it
// and return a new instance of the updated remote

Remote updatedremote = repo.Network.Remotes.Update(remote, r => r.Url = newUrl);
值得一提的是,大多数远程属性都可以通过遵循相同的模式进行更新。请随时查看 RemoteFixture.cs 测试套件以获取更详细的示例。

关于libgit2sharp - 在 libgit2sharp 中更改存储库的远程 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30256070/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com