LibGit2Sharp CheckoutPaths()

给你一囗甜甜゛ 提交于 2019-12-10 18:03:02

问题


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

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

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

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

回答1:


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


来源:https://stackoverflow.com/questions/22254932/libgit2sharp-checkoutpaths

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