protected override Repository OnPublish (string serverPath, FilePath localPath, FilePath[] files, string message, ProgressMonitor monitor) { // Initialize the repository RootRepository = new LibGit2Sharp.Repository (LibGit2Sharp.Repository.Init (localPath)); RootPath = localPath; RootRepository.Network.Remotes.Add ("origin", Url); // Add the project files ChangeSet cs = CreateChangeSet (localPath); foreach (FilePath fp in files) { RootRepository.Stage (RootRepository.ToGitPath (fp)); cs.AddFile (fp); } // Create the initial commit cs.GlobalComment = message; Commit (cs, monitor); RootRepository.Branches.Update (RootRepository.Branches ["master"], branch => branch.TrackedBranch = "refs/remotes/origin/master"); RetryUntilSuccess (monitor, credType => RootRepository.Network.Push (RootRepository.Head, new PushOptions { OnPushStatusError = delegate (PushStatusError e) { RootRepository.Dispose (); RootRepository = null; if (RootPath.Combine (".git").IsDirectory) Directory.Delete (RootPath.Combine (".git"), true); throw new VersionControlException (e.Message); }, CredentialsProvider = (url, userFromUrl, types) => GitCredentials.TryGet (url, userFromUrl, types, credType) })); return this; }