Setting upstream on a repo

戏子无情 提交于 2019-12-08 03:56:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!