Skip to content
kobake edited this page Aug 12, 2018 · 4 revisions

git-pull

Pulls updates from a remote using Authentication

Git

$ git pull

LibGit2Sharp

using (var repo = new Repository("path/to/your/repo"))
{
    // Credential information to fetch
    LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions();
    options.FetchOptions = new FetchOptions();
    options.FetchOptions.CredentialsProvider = new CredentialsHandler(
        (url, usernameFromUrl, types) =>
            new UsernamePasswordCredentials()
            {
                Username = USERNAME,
                Password = PASSWORD
            });

    // User information to create a merge commit
    var signature = new LibGit2Sharp.Signature(
        new Identity("MERGE_USER_NAME", "MERGE_USER_EMAIL"), DateTimeOffset.Now);

    // Pull
    Commands.Pull(repo, signature, options);
}
Clone this wiki locally