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?

有帮助吗?

解决方案

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

Commands.Stage(repo, "*");

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top