5

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?

Joannes Vermorel
  • 8,976
  • 12
  • 64
  • 104

3 Answers3

17

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

Commands.Stage(repo, "*");
Anik Saha
  • 4,313
  • 2
  • 26
  • 41
5

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

yorah
  • 2,653
  • 14
  • 24
  • I *do* agree that the xml doc is pretty thin about this. Would you feel like sending a pull request to improve this? ;-) – nulltoken Apr 03 '14 at 17:58
0

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

Nick
  • 11
  • 2