Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LibGit2Sharp CheckoutPaths()

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 });
like image 689
JoeLiBuDa Avatar asked Jul 26 '26 00:07

JoeLiBuDa


1 Answers

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);
like image 77
jamill Avatar answered Jul 27 '26 18:07

jamill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!