Question

I have an external process that applies changes to files part of a local Git repository initially cloned through libgit2sharp. I would like to perform - through libgit2sharp - the equivalent of the command git add *, followed by git commit -m "Hello World". The documentation of the Repository class is thin on this.

How can it be done?

Was it helpful?

Solution

In 2020 the code structure has been changed. Now its like==>

Commands.Stage(repo, "*");

OTHER TIPS

To simulate git add *, you can use:

 repo.Index.Stage("*");

Then, in order to create a commit, you can use the repo.Commit(string, Signature, Signature) method, which will commit all changes staged in the index.

For more information about the Commit feature, you can also rely on the CommitFixture tests (look for the AddCommitToRepo private method).

To stage all my changes, I had to use: repo.Stage(*);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top