在仓库上设置上游 [英] Setting upstream on a repo

查看:162
本文介绍了在仓库上设置上游的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用libgit2sharpremote中拉出master分支.

I am trying to pull the master branch from a remote using libgit2sharp.

有时我必须将remote更改为其他网址,并从该remote中提取.
当我更改remote并尝试到pull时,出现此错误:

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

我知道我必须执行git branch --set-upstream-to=origin/master master来使用git来解决此问题,但是我想知道如何使用libgit2sharp来做到这一点?

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?

推荐答案

给出mybranch,一个Branch实例,该实例已经配置为跟踪origin远程服务器中的分支.

Given mybranch, a Branch instance, which is already configured to track a branch in the origin remote.

如果您愿意做的就是将远程服务器重新配置(同时保留本地和远程跟踪分支配置),再配置为另一个(例如"myOtherRemote"),那么下面的代码应该可以解决问题. /p>

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");

这篇关于在仓库上设置上游的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆