2017-03-06 14 views
0

githubに行って新しいプロジェクトを作成したばかりですが、これまではreadmeとgitignoreファイルしかありません。しかし、私はこのエラーの背後にある論理を理解し、私はgit push -u origin masterを使用して私のプロジェクトをプッシュしたいと思いますが、私はこのリモートで新しいファイルを無視しながら、gitで新しいプロジェクトをプッシュする方法(readmeのような)

$ git push -u origin master 
To https://github.com/user/project.com 
! [rejected]  master -> master (fetch first) 
error: failed to push some refs to 'https://github.com/user/project.com' 
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. 

を含むエラーメッセージが表示されます、私は

git init 
git add . 
git commit -m "initial commit" 
git remote add origin https://github.com/user/repo.git 

を使用してgitのために追加したローカルでのプロジェクトを持っていますしかし、解決策は何ですか? ローカルの.gitignoreファイルを消去する可能性があるので、強制的にプッシュしなくてもこれを無視しますか?

+1

あなたはプル--rebaseをgitのことができ、かつ競合がある場合、それはあなたを教えてくれます。 –

+0

プッシュするときに--forceフラグ – Matt

+0

@martinjakubikは--rebaseが好きなファイルをいくつか消去しますか? – user7342807

答えて

0

update:何らかの理由で、この提案はユーザーのファイルをローカルファイルシステムから削除しました。

私が調査している間、私は今のところそれを残したいと思っていますが、私はあなたの答えに従わないことをお勧めします。


これは動作するはずです:

git pull (or I prefer git pull --rebase) 

<manually resolve any conflicts by editing the text files> 

git merge --continue (or git rebase --continue if you used rebase above) 

git push 
+0

チャットに移動できますか? 'git pull --rebase'でしたか? '最初に、頭を巻き戻してその上にあなたの作品を再生するために4分間。' – user7342807

+0

あなたはプロキシの背後にいますか? –

+0

私は公共の無線LANを使用していますが、レポはプライベートです。 – user7342807