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 fetch

Jason edited this page Jan 15, 2015 · 3 revisions

git-fetch

Fetch updates from a remote

####Git

$ git fetch origin
```
#### LibGit2Sharp
```csharp
using (var repo = new Repository("path/to/your/repo"))
{
    Remote remote = repo.Network.Remotes["origin"];
    repo.Network.Fetch(remote);
}
```

### Fetch all remotes, using authentication
####Git

$ git fetch --all

#### LibGit2Sharp
```csharp
using (var repo = new Repository("path/to/your/repo"))
{
    foreach(Remote remote in repo.Network.Remotes)
    {
        FetchOptions options = new FetchOptions();
        options.CredentialsProvider = new CredentialsHandler(
            (url, usernameFromUrl, types) => 
                new UsernamePasswordCredentials() 
                {
                    Username = USERNAME,
                    Password = PASSWORD
                });
        repo.Network.Fetch(remote, options);
    }
}

Clone this wiki locally

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