2017-11-14 12 views
1

私はlibgit2sharpを使用して、ファイルが生成されるとリポジトリにプッシュします。libgit2sharp - Git - 非高速転送可能な参照をプッシュできません

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); 
} 

しかし、これは私が今、いくつかのファイルについては、以下のエラーメッセージを取得していますし、プッシュは、任意のファイルに対して発生していない、いくつかの時間のための偉大な作業と問題なくリポジトリにプッシュされています。 (サーバログからの)

エラーメッセージ:

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) 

私はエラーで検索しましたが、これをカバーして何かを見つけることができませんか?また、このリポジトリがAzure Webサーバーにあるので、libgit2sharp C#コードを介してGitコマンドを実行したと仮定します。コマンドラインGitコマンドを実行する権限がないためです。

この件に関するご意見はありがとうございます。

答えて

3

変更がリモートのブランチから早送りできない場合は、他の誰かがリポジトリのブランチを更新したことを意味します。リモートからフェッチし、リモートのブランチとマージしてから、プッシュする必要があります。

また、refspecの先頭に+(たとえば、+refs/heads/master)を付けると、強制的にプッシュすることができます。

関連する問題