2017-11-14 13 views
1

libgit2sharp을 사용하여 생성 된 파일을 저장소로 푸시합니다. libgit2sharp - 힘내 - 빠른 전달이 불가능한 참조를 푸시 할 수 없음

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 웹 서버에 앉아 있기 때문에 libgit2sharp C# 코드를 통해 모든 Git 명령을 실행할 수 있다고 가정합니다. 명령 행 Git 명령을 실행할 수있는 권한이 없기 때문입니다.

이 도움말에 감사드립니다.

답변

3

변경 사항이 원격 브랜치에서 빨리 감기가 가능하지 않으면 다른 사람이 저장소의 브랜치를 업데이트했음을 의미합니다. 리모컨에서 가져와 원격 지점과 병합해야합니다. 그러면 밀어 넣을 수 있습니다.

또는 refspec 앞에 + (예 : +refs/heads/master)을 붙이면 강제로 푸시 할 수 있습니다.