在repo上设置上游

时间:2015-02-16 09:44:17

标签: git libgit2 libgit2sharp

我正在尝试使用masterremote提取libgit2sharp分支。

有时我必须将remote更改为其他网址并从remote拉出来。
当我更改remote并尝试pull时,我收到此错误:

There is no tracking information for the current branch

我知道我必须使用git git branch --set-upstream-to=origin/master master解决此问题,但我想知道如何使用libgit2sharp执行相同操作?

1 个答案:

答案 0 :(得分:0)

给定mybranch,一个Branch实例,它已配置为跟踪origin远程中的分支。

如果你愿意做的就是重新配置遥控器(同时保持本地和远程跟踪分支配置),再到另一个(例如“myOtherRemote”),那么下面的代码应该可以解决问题。 / p>

repo.Branches.Update(myBranch, b => b.Remote = "myOtherRemote");