I'm using libgit2sharp to push files to a repository once they have been generated.
using (var repo = new Repository(RepositoryPath))
{
// Stage the file
Commands.Stage(repo, "*");
// Create the committer's signature and commit
Signature author = new Signature("translator", "example.com", DateTime.Now);
Signature committer = author;
// Commit to the repository
Commit commit = repo.Commit($"Resx files updated {DateTime.Now}", author, committer);
Remote remote = repo.Network.Remotes["origin"];
var options = new PushOptions
{
CredentialsProvider = (_url, _user, _cred) =>
new UsernamePasswordCredentials
{
Username = _settings.GitUserName,
Password = _settings.GitPassword
}
};
repo.Network.Push(remote, @"refs/heads/master", options);
}
This has been working great for some time and pushing to repository without issue, however I am now getting the below error message for some files and the push does not occur for any files.
Error message (from server log):
Message: cannot push non-fastforwardable reference
StackTrace: at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Proxy.git_remote_push(RemoteHandle remote, IEnumerable`1 refSpecs, GitPushOptions opts)
at LibGit2Sharp.Network.Push(Remote remote, IEnumerable`1 pushRefSpecs, PushOptions pushOptions)
at LibGit2Sharp.Network.Push(Remote remote, String pushRefSpec, PushOptions pushOptions)
at Westwind.Globalization.Core.Utilities.DbResXConverter.SyncToGit(String resourceSet)
I have searched for error but cannot find anything that covers this? Also as this repository is sat on a Azure web server I assume I would have run any Git commands via libgit2sharp C# code as I would not have permissions to run command line Git commands.
Any help appreciated on this one.