更改 libgit2sharp 中存储库的远程 url
Changing the remote url of a repository in libgit2sharp
我们如何更改存储库的远程 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 测试套件以获取更详细的示例。
他们已经使 public 虚拟远程更新(Remote remote, params Action[] actions) 过时了。
var newUrl = "https://github.com/owner/my_repository.git";
WorkingRepository.Network.Remotes.Update("origin", r => { r.Url = uri; });
我们如何更改存储库的远程 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 测试套件以获取更详细的示例。
他们已经使 public 虚拟远程更新(Remote remote, params Action[] actions) 过时了。
var newUrl = "https://github.com/owner/my_repository.git";
WorkingRepository.Network.Remotes.Update("origin", r => { r.Url = uri; });