Githubで! [rejected] main -> main (non-fast-forward)とか言うエラーが出た話

2023年11月16日木曜日

Github

 commitしかしないので半分クラウドみたいな使い方になってるGithub君が変なエラーを出してそれを解決した時のメモ。

bloggerでコンソール表示の仕方がわからないので黒背景に白文字をコンソールとする。



$ git push origin main

したら

$ ! [rejected]        main -> main (non-fast-forward)

error: failed to push some refs to 'https://github.com/hogehohe/huga.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.

とよくわからんエラーが出てきたのでググるとリポジトリ作成の時にライセンスやらReadmeやらをGithub側で設定すると出るらしい。←????


とりあえずいろいろググって

$ git merge --allow-unrelated-histories origin/main

$ git push origin main

したら

Enumerating objects: 6, done.

Counting objects: 100% (6/6), done.

Delta compression using up to 8 threads

Compressing objects: 100% (4/4), done.

Writing objects: 100% (5/5), 1.90 KiB | 1.90 MiB/s, done.

Total 5 (delta 0), reused 0 (delta 0), pack-reused 0

To https://github.com/hogehoge/huga.git

   xxxxxxx..xxxxxxx  main -> main

できた。