2016-08-23 3 views
0

나는 remote_branchremote git repository을 가지고 있습니다. 내 컴퓨터에 remote_repository을 복제하고 local_branch을 만들었습니다.원격 및 로컬 저장소

이제 push으로 변경하려면 local_branch에서 remote_branch으로 변경하십시오. 은 지내요, 나는 upstream flag

git branch --set-upstream-to=origin/remote_branch local_branch 

I 다음 commitstage 내 변경을 설정하고 remote_branch에 변경 git push받는보십시오.

그러나
To [email protected] 
! [rejected]  remote_branch -> remote_branch (non-fast-forward) 
error: failed to push some refs to '[email protected]' 
hint: Updates were rejected because a pushed branch tip is behind its 
remote counterpart. If you did not intend to push that branch, you may 
want to specify branches to push or set the 'push.default' 
configuration variable to 'simple', 'current' or 'upstream' to push 
only the current branch. 

, 나는 push 때 의미가 있습니다

git push origin local_branch:remote_branch 

변경 : 나는이 메시지가 나타납니다. 내가 뭘 잘못하고 있니?

답변

1

로컬 시스템에서 remote_branch이라는 브랜치에서 작업하는 것 같습니다. 이 브랜치는 원격 저장소에서 복제 할 때 로컬 시스템에 자동으로 작성됩니다. git push을 실행하면 기본값은 현재 분기에서 변경 사항을 푸시하는 것입니다. 따라서 먼저 git checkout local_branch을 수행하고 커밋을 제공해야합니다.

일반적으로 원격 저장소와 같은 이름을 로컬로 사용하고 1 : 1 매핑을 사용하는 것이 좋습니다.

+0

트릭을하지 못했습니다. – Stophface

+0

다른 사람이 원격 저장소에 다른 커밋을 추가하는 동안 변경 사항 (커밋)을'local_branch'에 추가 한 것일 수 있습니까? 이 경우 밀어 넣기 전에 변경 내용을 병합하거나 리베이스해야 할 수 있습니다. 실제로 밀어 넣기가 수행되었으므로 다른 밀어 넣기 작업이 수행되었습니다. 'gitk --all'은 현재 상태를 시각화하는 데 도움이 될 수 있습니다. –

+0

nope. 나는'local_branch'에서'remote_branch'을 꺼내서'local_branch'에서 무엇인가를 변경하고'local_branch'을'remote_branch'로 푸시하려고했습니다. 같은 효과. – Stophface