LibGit2Sharp CheckoutPaths() [英] LibGit2Sharp CheckoutPaths()

查看:161
本文介绍了LibGit2Sharp CheckoutPaths()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个提交(49916 .....),现在我想签出一个提交到工作目录的文件。该文件被命名为NEW.txt。
如果我输入

I did a commit (49916.....) now i want to checkout one file of the commit into the working dir. The file is named NEW.txt. If i type


Git checkout 49916 NEW.txt

Git checkout 49916 NEW.txt

转换为Git Bash,它会在我的工作目录中创建NEW.txt文件。

into Git Bash it creates the NEW.txt file with the content in my working dir.

但是我的LibGit2Sharp命令不想工作。我做错了什么?

But my LibGit2Sharp command does not want to work. What am I doing wrong?

       var repo = new Repository(repopath);
       var checkoutPaths = new[] { "NEW.txt"};    
       repo.CheckoutPaths("49916", checkoutPaths);

我读过关于checkoutpaths函数的每篇文章。但我无法得到它的工作。我从LibGit2Sharp签出测试文件中获得了该函数。

I read every article which i could find about the checkoutpaths function. But i cant get it working. I got the function from the LibGit2Sharp checkout test file.

            repo.CheckoutPaths(checkoutFrom, new[] { path });


推荐答案

运行代码时会发生什么?它是否运行完成,但工作目录中没有更改?如果您尝试使用 CheckoutModifiers.Force 选项结帐,会发生什么情况?

What happens when you run that code? Does it run to completion but there are no changes in the working directory? What happens if you try to checkout with the CheckoutModifiers.Force option?

CheckoutOptions options = new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force };
repo.CheckoutPaths("49916", checkoutPaths, options);

这篇关于LibGit2Sharp CheckoutPaths()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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