2017-03-28 12 views
2

R(Coursera Course)で2回目のプログラミングを終了しました。
その後、自分のGitHubアカウントのローカルレポをグローバルレポに関連づけてコミットし、push -u origin masterとしました。git push -u origin masterが失敗しました

しかし、私は次のエラーました:その後、私は私のgetアカウントでレポを引き出し、マスターへの分岐とチェックアウトをしたが、私は以下のようなメッセージ受信

! [rejected]  master -> master (fetch first) 
error: failed to push some refs to 'https://github.com/RofaidaG/ProgrammingAssignment2' 
hint: Updates were rejected because the remote contains work that you do 
hint: not have locally. This is usually caused by another repository pushing 
hint: to the same ref. You may want to first integrate the remote changes 
hint: (e.g., 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

を:

! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to 
hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Integrate the remote changes (e.g. 
hint: 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

をどうすればいいですか?

+0

マスターブランチを引き出すことはできますか? – Prabhakar

+0

もう一度マスターにチェックアウトした後に 'git pull'を実行したことはありますか?原因は上記の失敗したgit pushと同じようです。 – MarkSkayff

答えて

0

あなたのコミットは専用の分岐上にある場合は、代わりにしてみてください:

git fetch 
git checkout mybranch (you might be already on that branch) 
git rebase origin/master 
git push -u origin mybranch 

しかし、その後、あなたのコミットは、ローカルのmasterブランチ上にある場合、あなたはマスターにプッシュすることになっている場合:

git checkout master 
git fetch 

# replay your local commits on top of origin/master 
git pull --rebase 
# check everything is still working 

git push 
0

これは、コードをリポジトリにプッシュする前に、ライセンスまたはREADMEファイルを追加した場合に発生します。

関連する問題