} // End Sub Reset public virtual void SetGlobalCredentials(string path, string userName, string password) { NGit.Transport.CredentialsProvider credentials = new NGit.Transport.UsernamePasswordCredentialsProvider(userName, password); // Or globally as the default for each new command NGit.Transport.CredentialsProvider.SetDefault(credentials); } // End Sub SetGlobalCredentials
public static void WithCreds() { Git repository = Git.Open(@"C:\Git\NGit"); NGit.Transport.UsernamePasswordCredentialsProvider credentials = new NGit.Transport.UsernamePasswordCredentialsProvider("username", "password"); // On a per-command basis NGit.Transport.FetchResult fetch = repository.Fetch() .SetCredentialsProvider(credentials) .Call(); // Or globally as the default for each new command NGit.Transport.CredentialsProvider.SetDefault(credentials); }
} // End Sub SetGlobalCredentials public virtual void FetchWithCredentials(string path, string userName, string password) { NGit.Api.Git repository = NGit.Api.Git.Open(path); NGit.Transport.CredentialsProvider credentials = new NGit.Transport.UsernamePasswordCredentialsProvider(userName, password); // On a per-command basis NGit.Transport.FetchResult fetch = repository.Fetch() .SetCredentialsProvider(credentials) .Call(); CloseRepository(repository); } // End Sub FetchWithCredentials