LoginSignup
0
0

More than 3 years have passed since last update.

Github側でREAD.meをいじったら、gitにpushできなくなった

Last updated at Posted at 2020-07-25

pushできていたリポジトリにpushできなくなった。
恐らくREADME.mdの内容をgithubのサイト上で変更したことが原因だと思われるが、解決方法がわからない。

結論から言えば、この記事通りにやったら無事解決できた。

以下、一通り出たエラーとやったことを書き残しておく。

$git push origin master 
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/…/リポジトリ名.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.

とりあえずpullしろと言われているようなので、pullしてみたが似たようなエラーが。

$ git pull origin master
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/ユーザー名/リポジトリ名
 * branch            master     -> FETCH_HEAD
   060ee7a..4c90029  master     -> origin/master
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.

やはりREADME.mdが原因の様子。
正直gitはpushとpullしかしたことがない私には、mergeがなんなのかよくわからないが、とりあえずエラーをググると$git pushで解決できると書いてあったので実行してみた。

$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

$git push --set-upstream origin master
To https://github.com/ユーザー名/リポジトリ名.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/ユーザー名/リポジトリ名.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.

うーん。やってみたが解決しないので、もう一度git push origin masterしてみる

$ git push origin master
To https://github.com/ユーザー名/リポジトリ名.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/ユーザー名/リポジトリ名.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.
$ git pull origin master
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

と、若干違うエラーが出たので、再度検索してみたら出てきたこの記事を参考に、その通りに実行したら無事解決!

0$ git add -A
$ git commit
[master 015118d] Merge branch 'master' of https://github.com/ユーザー名/リポジトリ名

$ git pull origin master
From https://github.com/ユーザー名/リポジトリ名
 * branch            master     -> FETCH_HEAD
Already up to date.

$ git push origin master
Enumerating objects: 52, done.
Counting objects: 100% (38/38), done.
Delta compression using up to 4 threads
Compressing objects: 100% (20/20), done.
Writing objects: 100% (20/20), 2.46 KiB | 838.00 KiB/s, done.
Total 20 (delta 10), reused 0 (delta 0)
remote: Resolving deltas: 100% (10/10), completed with 8 local objects.
remote:
remote: GitHub found 5 vulnerabilities on ユーザー名/リポジトリ名's default branch (1 high, 3 moderate, 1 low). To find out more, visit:
remote:      https://github.com/ユーザー名/リポジトリ名/network/alerts
remote:
To https://github.com/ユーザー名/リポジトリ名.git
   4c90029..015118d  master -> master
0
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
0
0