问题
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