5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git push -u origin masterでrejectにハマる

Posted at

#git push -u origin masterできない!!
N予備校Node.jsの序盤にて
ローカルで作ったファイルをgithubにアップするため、github上にリポジトリを作って

git push -u origin master

しかし

To github.com:○○○/my-first-node-js.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:○○○/my-first-node-js.git'
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】git pushがrejectされたときの対応方法
https://www.softel.co.jp/blogs/tech/archives/3569

対応方法 3)fetch して rebase するを実行しました

git fetch    (リモートの変更を取ってきて)
git rebase origin/master

うまく行った…!

$ git push -u origin master
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 1.55 KiB | 794.00 KiB/s, done.
Total 14 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), done.
To github.com:tsu2626/my-first-node-js.git
   dadbbc3..70bd482  master -> master

もしかしてREADMEファイルのせいで差分ができてたのか?
結局、理由まではわからなかった

コメントお待ちしております

5
3
1

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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?