2014-01-30 2 views
-2

git push 명령을 사용했으며 지금까지 예상대로 작동했습니다. 오늘 git 명령을 테스트하는 동안 마스터 대신 HEAD로 푸시하면 아래 표시된 오류없이 작동한다는 것을 알았습니다. 이 두 명령의 차이점을 배우고 올바른 명령을 선택할 수 있습니다. 머리로 밀어github에 파일 푸시

# git push origin master 
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts. 
To [email protected]:shan/mobileapp 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to '[email protected]:shan/mobileapp' 
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. 


# git push origin HEAD 
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts. 
Counting objects: 23, done. 
Compressing objects: 100% (18/18), done. 
Writing objects: 100% (19/19), 2.56 KiB, done. 
Total 19 (delta 11), reused 0 (delta 0) 
To [email protected]:shan/mobileapp 
* [new branch]  HEAD -> topic/wip 

만든 것 같다 지점이라고 지금 마스터와 가지 주제/WIP를 병합 할 수 있습니다

주제/WIP. 그러나 위에서 언급 한 첫 번째 명령이 예상대로 작동하기를 바랍니다. 마스터와 병합 할 임시 분기를 만들 필요가 없습니다.

+2

오류 메시지에 설명 된대로 원본/마스터를 밀어 넣기 전에 병합해야합니다. – geoffspear

답변

2

git HEAD은 기본적으로 "현재 커밋"을 의미합니다. 따라서 wip 브랜치를 확인한 경우 git push origin HEADgit push origin wip과 동일하며 원격 브랜치 origin/wip으로 푸시하여 필요한 경우 두 번째 예와 같이 생성합니다.

마스터로 푸시 할 수없는 이유는 지사의 로컬 복사본이 오래된 것입니다. 푸시하기 전에 로컬 사본을 업데이트해야합니다 : git pull origin master.

관련 문제