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ファイルを消去する可能性があるので、強制的にプッシュしなくてもこれを無視しますか?
あなたはプル--rebaseをgitのことができ、かつ競合がある場合、それはあなたを教えてくれます。 –
プッシュするときに--forceフラグ – Matt
@martinjakubikは--rebaseが好きなファイルをいくつか消去しますか? – user7342807