How can I get the user's identity and signature using libgit2sharp in order to create commits? The documentation only shows how to create a brand new signature, but I want to use the one the user has already set up using git config.
The documentation page at https://github.com/libgit2/libgit2sharp/wiki/Git-commit only shows how to create a signature, not how to retrieve the user's identity.
// Create the committer's signature and commit
Signature author = new Signature("James", "@jugglingnutcase", DateTime.Now);
Signature committer = author;
// Commit to the repository
Commit commit = repo.Commit("Here's a commit i made!", author, committer);
                This is done by using the Configuration object, which you can get from the repository directly:
Configuration config = repo.Config;
Signature author = config.BuildSignature(DateTimeOffset.Now); // or something else if you want to commit at a different time
You can then create the commit the regular way, with repo.Commit(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With