-
Notifications
You must be signed in to change notification settings - Fork 890
git fetch
vpfau edited this page Nov 7, 2018
·
6 revisions
$ git fetch origin
string logMessage = "";
using (var repo = new Repository("path/to/your/repo"))
{
var remote = repo.Network.Remotes["origin"];
var refSpecs = remote.FetchRefSpecs.Select(x => x.Specification);
Commands.Fetch(repo, remote.Name, refSpecs, null, logMessage);
}
Console.WriteLine(logMessage);
using (var repo = new Repository("path/to/your/repo"))
{
Remote remote = repo.Network.Remotes["origin"];
repo.Network.Fetch(remote);
}
$ git fetch --all
string logMessage = "";
using (var repo = new Repository("path/to/your/repo"))
{
FetchOptions options = new FetchOptions();
options.CredentialsProvider = new CredentialsHandler((url, usernameFromUrl, types) =>
new UsernamePasswordCredentials()
{
Username = "USERNAME",
Password = "PASSWORD"
});
foreach (Remote remote in repo.Network.Remotes)
{
IEnumerable<string> refSpecs = remote.FetchRefSpecs.Select(x => x.Specification);
Commands.Fetch(repo, remote.Name, refSpecs, options, logMessage);
}
}
Console.WriteLine(logMessage);
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);
}
}