質問編集履歴

2

試したことを追加

2024/04/07 05:19

投稿

_chii
_chii

スコア50

test CHANGED
File without changes
test CHANGED
@@ -70,5 +70,22 @@
70
70
  fatal: refusing to merge unrelated histories
71
71
  ```
72
72
 
73
+ #### 別の試した方法
74
+
75
+ 参考にした記事
76
+ https://wonderful-tereshkova-38f91d.netlify.app/GitHub%E3%81%B8%E3%81%AEpush%E3%81%8C%E3%80%8Cfetch%20first%E3%80%8D%E3%81%A8%E8%A1%A8%E7%A4%BA%E3%81%95%E3%82%8C%E3%81%A6rejected%E3%81%A8%E3%81%AA%E3%81%A3%E3%81%9F%E3%81%A8%E3%81%8D%E3%81%AE%E5%AF%BE%E5%87%A6/
77
+
78
+ 上記の記事を参考にして git status でリモートとローカルでマージされていないファイル(わたしの場合はREADME.md)を追加しました。
79
+
80
+ 「これでやっとpushできる」と思ったのですが、これでもpushは同じ結果でした。
81
+ 再度 git status をしても以下のように問題ありませんでした。
82
+ 本当にわかりません...
83
+
84
+ ```
85
+ % git status
86
+ On branch main
87
+ nothing to commit, working tree clean
88
+ ```
89
+
73
90
  ### 補足
74
91
  特になし

1

pushコマンドを実行したときの結果を具体的に記述

2024/04/07 02:49

投稿

_chii
_chii

スコア50

test CHANGED
File without changes
test CHANGED
@@ -27,34 +27,47 @@
27
27
 
28
28
  ##### 上記の詳細・結果
29
29
  五月雨になりますが、試したことを記述します
30
- ※ちなみに強制pushも試してみましたがそれもだめでした...
31
-
32
30
  こちらご教授いただけないでしょうか🙇‍♀️
33
31
 
32
+ ※追記
33
+ pushと強制pushを実行したときのコマンドとそのエラーメッセージを表示を以下に記述します
34
+
35
+ 以下は一般的なpush
34
36
  ```
35
- % git merge --allow-unrelated-histories origin/main
37
+ % git push -u origin main
38
+ To https://github.com/○○/○○.git
36
- merge: origin/main - not something we can merge
39
+ ! [rejected] main -> main (non-fast-forward)
40
+ error: failed to push some refs to 'https://github.com/○○/○○.git'
41
+ hint: Updates were rejected because the tip of your current branch is behind
42
+ hint: its remote counterpart. If you want to integrate the remote changes,
43
+ hint: use 'git pull' before pushing again.
44
+ hint: See the 'Note about fast-forwards' in 'git push --help' for details.
37
45
  ```
38
46
 
47
+ 強制push
39
48
  ```
40
- % git merge
49
+ % git push -u origin main -f
50
+ Enumerating objects: 98, done.
51
+ Counting objects: 100% (98/98), done.
52
+ Delta compression using up to 8 threads
53
+ Compressing objects: 100% (85/85), done.
54
+ Writing objects: 100% (96/96), 706.14 KiB | 176.54 MiB/s, done.
55
+ Total 96 (delta 9), reused 92 (delta 7), pack-reused 0
56
+ remote: Resolving deltas: 100% (9/9), done.
57
+ remote: fatal: did not receive expected object cc2c1e6b0bf740ddb2ff643d8666d9c4c9d0b1aa
58
+ error: remote unpack failed: index-pack failed
59
+ To https://github.com/○○/○○.git
41
- fatal: No remote for the current branch.
60
+ ! [remote rejected] main -> main (failed)
61
+ error: failed to push some refs to 'https://github.com/○○/○○.git'
42
62
  ```
43
63
 
44
- ```
45
- % git remote -v
46
- origin https://github.com/○○/○○.git (fetch)
47
- origin https://github.com/○○/○○.git (push)
64
+ ちなみにhintに書かれているpullを試した結果です(下記を実行したあとにpushをしてもだめでした)
48
- ```
49
65
 
50
66
  ```
51
- % git merge origin/main
67
+ % git pull origin main
52
- merge: origin/main - not something we can merge
68
+ From https://github.com/○○/○○.git
53
- ```
69
+ * branch main -> FETCH_HEAD
54
-
55
- ```
56
- % git merge --allow-unrelated-histories origin/main
70
+ fatal: refusing to merge unrelated histories
57
- merge: origin/main - not something we can merge
58
71
  ```
59
72
 
60
73
  ### 補足