はじめてのGitHubへのpushでエラーが出る
はじめてGitHubにpushしたらエラーが出たときの対処法
以下エラー内容▼
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Monet13/gasTest.git'
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.
原因
GitHubにレポジトリを作ったときREADMEが自動作成されるが、それがローカルにはないのが原因。
なのでまずはpullするなりして最新のリモートを取り込んでね!って書いてあります
対処方法
1.fetchする
$ git fetch
2.mergeする
$ git merge origin/master
3.READMEがnew fileとして反映されていることを確認
$ git status
On branch master
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
new file: README.md
4.addしてcommitする
$ git add .
$ git commit -m 'README追加'
5.最後にpushする!
$ git push -u origin master
リモートを確認すると、pushできていると思います
以上!
Author And Source
この問題について(はじめてのGitHubへのpushでエラーが出る), 我々は、より多くの情報をここで見つけました https://qiita.com/one_punch_man/items/7f7847f6b2d9bf79feba著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .