LoginSignup
2
0

More than 3 years have passed since last update.

はじめてのGitHubへのpushでエラーが出る

Posted at

はじめてGitHubにpushしたらエラーが出たときの対処法:blush:

以下エラー内容▼

 ! [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するなりして最新のリモートを取り込んでね!って書いてあります:grinning:

対処方法

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できていると思います:blush:
以上!

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0