2013-01-12 3 views
3

Github가 내 프로젝트의 기본 저장소입니다 (단지 "origin"이 "github"로 이름이 변경됨). "git push github master"가 작동하더라도 "git push"가 "non-fast-forward updates"오류를 발생 시키도록 어떤 일이 발생했습니다. "git pull"및 "git pull github master"는 둘 다 최신 상태를 나타냅니다. 어떻게하면 (a) Github에 병합되지 않은 변경 사항이 없는지, (b) 빨리 감기가 아닌 오류를 수정할 수 있습니까?Git은 'git pull'후에도 'non-fast-forward updates'오류를 표시합니다.

+refs/heads/*:refs/remotes/github/* 

간단한 git push 밀어 것 :

$ git status 
# On branch master 
nothing to commit (working directory clean) 
$ git pull 
Already up-to-date. 
$ git pull github master 
From github.com:MikeBlyth/mission_net 
* branch   master  -> FETCH_HEAD 
Already up-to-date. 
$ git push github master 
Everything up-to-date 
$ git push 
To [email protected]:MikeBlyth/mission_net.git 
! [rejected]  add_command -> add_command (non-fast-forward) 
error: failed to push some refs to '[email protected]:MikeBlyth/mission_net.git' 
To prevent you from losing history, non-fast-forward updates were rejected 
Merge the remote changes (e.g. 'git pull') before pushing again. See the 
'Note about fast-forwards' section of 'git push --help' for details. 

내 자식 설정 파일은 설명이 "github"원격에 사용되는 기본 refspec과 관련이있을 수

[core] 
    repositoryformatversion = 0 
    filemode = true 
    bare = false 
    logallrefupdates = true 
[remote "github"] 
    url = [email protected]:MikeBlyth/mission_net.git 
    fetch = +refs/heads/*:refs/remotes/github/* 
[branch "master"] 
    remote = github 
    merge = refs/heads/master 
[remote "heroku"] 
    url = [email protected]:joslink.git 
    fetch = +refs/heads/*:refs/remotes/heroku/* 
    merge = refs/heads/master 
[remote "heroku"] 
url = [email protected]:joslink.git 
fetch = +refs/heads/*:refs/remotes/heroku/* 
+0

초기 답변을 변경했습니다. – VonC

+0

michas와 VonC의 답변을 요약하면 "git push"는 기본적으로 모든 브랜치를 푸시하려고하며 동기화되지 않은 브랜치 (add_command)가 있습니다. –

답변

2

'git push'구문은 명시 적 버전과 약식 버전을 모두 지원합니다. 명시적인 버전 git push github master이 적합합니다. 속기 버전 git push은 아닙니다.

속기 버전을 사용한다면 git에게 사용할 리모콘과 원격 브랜치로 푸시 될 로컬 브랜치를 알려주지 않습니다. 그러므로 자식은 당신이 의미하는 바를 추측해야합니다.

당신은 원격 및 push.default 설정의 설정과이를 구성 할 수 있습니다

push.default 
     Defines the action git push should take if no refspec is given on 
     the command line, no refspec is configured in the remote, and no 
     refspec is implied by any of the options given on the command line. 
     Possible values are: 

     · nothing - do not push anything. 

     · matching - push all matching branches. All branches having the 
      same name in both ends are considered to be matching. This is 
      the default. 

     · upstream - push the current branch to its upstream branch. 

     · tracking - deprecated synonym for upstream. 

     · current - push the current branch to a branch of the same 
      name. 

현재 브랜치에 의해 추적 어떤 지점 확인 git branch -vv에서보세요. 그런 다음 git config --get push.default을 확인하여 예상 한대로 작동하는지 확인하십시오.

2

입니다

  • master 현재 지점이기 때문에 (여기서는 "github"), 마스터에 연결된 리모트
  • 모든 다른 분기 (masteradd_command 분기)

add_command는합니다 (git status 따라) github 리모컨과 동기화되지 않은 것입니다.

git checkout add_command 
git pull github 

그러면 git push이 작동합니다.

+0

git checkout 마스터가 분리 된 헤드 상태를 유지하기에 충분하지 않습니까? 그 때 그는 계속 당기고 밀 수 있습니다. – dunni

+0

@dunni하지만 그는 이미 자신의 지위에 따라 마스터에 있습니다. 이 시점에서,'reset -hard'는 로컬과 리모트 "github"사이에 "non-fast-foward"상태가 없도록하는 가장 확실한 방법입니다. – VonC

+0

@dunni 사실, 나는 "분리 된 머리"가 근본 원인이라고 생각하지 않습니다. 나는 내 대답을 바꾸었다. – VonC