问题
I am trying to pull the master
branch from a remote
using libgit2sharp
.
Sometimes I have to change the remote
to a different url and pull from that remote
.
When I change the remote
and try to pull
I get this error:
There is no tracking information for the current branch
I know I have to do git branch --set-upstream-to=origin/master master
to fix this issue using git, but I wonder how can I do the same with libgit2sharp
?
回答1:
Given mybranch, a Branch
instance, which is already configured to track a branch in the origin
remote.
If all you're willing to do is reconfigure the remote (while keeping the local and remote tracking branch configuration), to another one (eg. "myOtherRemote"), then the following piece of code should do the trick.
repo.Branches.Update(myBranch, b => b.Remote = "myOtherRemote");
来源:https://stackoverflow.com/questions/28538479/setting-upstream-on-a-repo