How to do 'git add *' with libgit2sharp?
Asked Answered
E

3

6

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?

Erleena answered 1/4, 2014 at 15:7 Comment(0)
L
17

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

Commands.Stage(repo, "*");
Larisalarissa answered 11/5, 2020 at 11:5 Comment(0)
T
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).

Touristy answered 1/4, 2014 at 15:32 Comment(1)
I do agree that the xml doc is pretty thin about this. Would you feel like sending a pull request to improve this? ;-)Sense
P
-1

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

Portmanteau answered 3/6, 2016 at 14:29 Comment(1)
Looks more like comment than answerFlowerage

© 2022 - 2024 — McMap. All rights reserved.