使用Libgit2sharp执行没有结帐的拉 [英] Perform a pull without a checkout with Libgit2sharp

查看:129
本文介绍了使用Libgit2sharp执行没有结帐的拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从远程分支执行pull到本地分支,而不必检出本地分支。我已经在GitKraken之类的工具中看到过这种情况,并且已经在这里找到了一个命令行解决方案: https://stackoverflow.com/a/17722977 / 1326370 。但是,我一直无法弄清楚如何用Libgit2sharp来做到这一点。任何想法?

I'd like to perform a pull from a remote branch to a local branch without having to checkout the local branch. I've seen this done in tools like GitKraken and have found a command line solution here: https://stackoverflow.com/a/17722977/1326370. However, I haven't been able to figure out how to do this with Libgit2sharp. Any ideas?

推荐答案

您无法将远程合并到本地,而无需首先检查。 git pull 等于 git fetch; git merge 和 git merge always 将某些内容合并到当前分支中(即 HEAD 在您的工作目录中签出)

You cannot merge a remote into your local without checking that out first. git pull is equal to git fetch ; git merge, and git merge always merges something into the "current" branch (i.e., the HEAD checked out in your working directory).

现在,如果您实际上不需要合并拉,你的本地版本的分支,然后你可以做 git branch -D mybranch; git fetch; git分支mybranch起源/ mybranch 而不检出任何东西。我假设你的库应该支持这些命令。

Now, if you do not actually need a merge-pull because you want to throw your local version of the branch away, then you can do git branch -D mybranch ; git fetch ; git branch mybranch origin/mybranch without checking out anything. I assume your library should support those commands.

这篇关于使用Libgit2sharp执行没有结帐的拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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