Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

git push

jlee-tessik edited this page Jun 11, 2015 · 3 revisions

git-push

Pushes updates from a remote using Authentication

####Git

$ git push
```
#### LibGit2Sharp
```csharp
using (var repo = new Repository("path/to/your/repo"))
{
    LibGit2Sharp.PushOptions options = new LibGit2Sharp.PushOptions();
    options.CredentialsProvider = new CredentialsHandler(
        (url, usernameFromUrl, types) =>
            new UsernamePasswordCredentials()
            {
                Username = USERNAME,
                Password = PASSWORD
            });
    repo.Network.Push(repo.Branches[BRANCHNAME], options)
}
```
Another variant, using Remote to push to the origin:
```csharp
using (var repo = new Repository("path/to/your/repo"))
{
	Remote remote = repo.Network.Remotes["origin"];
	var options = new PushOptions();
	options.CredentialsProvider = (_url, _user, _cred) => 
		new UsernamePasswordCredentials { Username = "USERNAME", Password = "PASSWORD" };
	repo.Network.Push(remote, @"refs/heads/master", options);
}
```

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.