意図せずSubModuleが作成された場合は、「$ git rm -rf --cached <対象ファイル or path>」後、「$ git add <対象ファイル or path>」

GitGit BASH

目次一覧

 状態:-  閲覧数:245  投稿日:2022-10-20  更新日:2022-10-20
問題発生 / 意図せずSubModule / エラー原因は、Gitが管理しているレポジトリの重複

エラー対応


問題発生 / 意図せずSubModule / エラー原因は、Gitが管理しているレポジトリの重複

 閲覧数:123 投稿日:2022-10-20 更新日:2022-10-20

問題発生


「hoge」ディレクトリ追加後、「$ git add -A」コマンドを実行したら、「warning: adding embedded git repository: hoge」警告表示されました。
$ git add -A
warning: adding embedded git repository: hoge
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint:   git submodule add <url> hoge
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint:   git rm --cached hoge
hint:
hint: See "git help submodule" for more information.


意図せずSubModule


色々試行錯誤している内に、意図せずSubModuleが作成されてしまいました。
Githubのhogeフォルダに矢印が表示されています。
githubでフォルダに矢印が!やっと解決した話

$ git commit -m "public_html all"
fatal: 'git status --porcelain=2' failed in submodule hoge



エラー原因は、Gitが管理しているレポジトリの重複


新たに配置した「hoge」ディレクトリ内に、別のリポジトリが存在していたことがエラー原因
【Git】エラーの原因と対処法:warning: adding embedded git repository You’ve added another git repository inside your current repository

エラー対応

 閲覧数:79 投稿日:2022-10-20 更新日:2022-10-20

エラー対応


「hoge」ディレクトリ内の「.git」ディレクトリを手動削除。

意図せずSubModuleとして作成された「hoge」ファイル、削除せずに(残したまま)管理対象から外す。
$ git rm -rf --cached hoge
rm 'hoge'


作業ディレクトリ内の変更をステージングエリアへ追加してコミット候補にする
$ git add -A

インデックスに追加されたファイルをコミットする(コミットメッセージも指定する)
$ git commit -m "public_html all"
[main 05aadfb] public_html all
507 files changed, 33278 insertions(+), 1 deletion(-)
delete mode 160000 hoge
create mode 100644 "hoge/- \343\202\263\343\203\224\3
43\203\274.htaccess"


ローカルリポジトリ(mainブランチ)(の変更)を送信して、リモートリポジトリ(「origin」上の同名ブランチ)へ反映させる
$ git push origin main
Enumerating objects: 531, done.
Counting objects: 100% (531/531), done.
Delta compression using up to 8 threads
Compressing objects: 100% (521/521), done.
Writing objects: 100% (530/530), 21.91 MiB | 2.76 MiB/s, done.
Total 530 (delta 53), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (53/53), done.
To github.com:GitHubユーザー名/P48-First-Ranking-Service.git
  e5bd229..05aadfb  main -> main



Git BASH 作業履歴 2022/10/20 / P48 site-rank(First-Ranking-Service) / 「Add a README」後「git push -f origin main」実行したため、「README」削除

Git BASH 作業履歴 2022/10/20 / P48 site-rank(First-Ranking-Service) 2 / P25をP48のリポジトリへ反映させていたので、「git push -f origin main」で強制上書き実行



類似度ページランキング
順位 ページタイトル抜粋
1 意図せずSubModuleが作成された場合は、「$ git rm -rf --cached <対象ファイル or path>」後、「$ git add <対象ファイル or path>」 49
2 意図せずSubModule(ディレクトリに白い矢印)が作成された場合は、「$ git rm -rf --cached <対象ファイル or path>」後、「$ git add <対象ファイル or path>」 46
3 Git BASH 作業履歴 2022/10/21 / P28 site-ranking(4Th-Ranking-Service) / 他の「.git」ディレクトリが存在した状態のまま下記gitコマンドを実行したため、意図せず「submodule」化されてしまった例 26
4 「ERROR: Repository not found. fatal: Could not read from remote repository.」と表示された場合は、 25
5 「Twitter Developer」審査結果に通り、appを作成。しかし、いつの間にか「User is not Authorized」が表示されていたケース 24
6 Knuth–Morris–Pratt algorithm border 23
7 「Default branch」ではなく「Your branches」 23
8 「2023 年 4 月 30 日」前後にTwitterアカウントが「SUSPENDED This App has violated Twitter Rules and policies.」と表示された場合には、「Downgrade」ボタンを押した方がよいと思われます。 23
9 「Email sent! We sent you a new copy of the confirmation email.」と表示されているのに、メール受信出来ない 23
10 Git BASH 作業履歴 2022/10/20 / P48 site-rank(First-Ranking-Service) / 「Add a README」後「git push -f origin main」実行したため、「README」削除 22
11 「Twitter Developers」でアプリケーションを新規作成するためには? SMS認証用コードを確認可能な電話番号の登録が必要 21
12 Git BASH 作業履歴 2022/10/20 / P48 site-rank(First-Ranking-Service) 2 / P25をP48のリポジトリへ反映させていたので、「git push -f origin main」で強制上書き実行 21
13 「This App has violated Twitter Rules and policies. As a result, it can no longer be accessed. For assistance, submit a support ticket.」と表示された場合、 20
14 「Twitter Developers」でApp作成 20
15 we are unable to approve your developer application at this time. 19
16 You currently have access to a subset of Twitter API v2 endpoints 19
17 同じ携帯電話番号でも、複数の「Twitter Developers」アカウントを作成可能 19
18 「Twitter Developer」で、遭遇したエラー系メッセージ 19
19 Twitterにおける「name」「screen_name」「user_id」の意味は明確に異なる 18
20 「Windows10」へ「gitfor windows VERSION 2.18.0」をインストール 18
2024/4/19 19:08 更新
週間人気ページランキング / 4-12 → 4-18
順位 ページタイトル抜粋 アクセス数
1 動画対応 | プログラミング 7
1 Twitter アカウント管理 | Twitter Developer(Twitter) 7
2 本 | ブックマーク 6
3 GitHubリモートリポジトリ名には日本語を使用できない。使用すると、ハイフンへ自動置換されてしまう | GitHub(Git) 5
4 気になるアプリ | ブックマーク 3
4 Windows10で使用できるGitクライアント | GitHub(Git) 3
5 「Twitterデータ」対応 | Twitter Developer(Twitter) 1
5 Git BASH(Git) カテゴリー 1
5 同じ携帯電話番号でも、複数の「Twitter Developers」アカウントを作成可能 | Twitter Developer(Twitter) 1
5 2012年 1
5 Git BASH 作業履歴 2022/10/20 / P48 site-rank(First-Ranking-Service) / 「Add a README」後「git push -f origin main」実行したため、「README」削除 | Git BASH(Git) 1
5 SFC(プログラミング) カテゴリー 1
5 「Twitter API」は、2023 年 5 月 10 日時点では、SMS認証(電話番号登録)不要でプロジェクト作成できるよう仕様変更されています。 | Twitter API (Twitter) 1
5 3.作業ディレクトリ内へ、Gitの(空の)ローカルリポジトリを作成する / 4.作業ディレクトリ内の変更をステージングエリアへ追加してコミット候補にする / 5.インデックスに追加されたファイルをコミットする(コミットメッセージも指定する) 1
5 6.ローカルリポジトリに、リモートリポジトリを設定する / ローカルリポジトリに設定されている、リモートリポジトリ内容を一覧表示(URLも表示) / ローカルリポジトリ(mainブランチ)(の変更)を送信して、リモートリポジトリ(「origin」上の同名ブランチ)へ反映させる 1
5 和田晃一良 年表 1
5 RTだけ表示するやつ / 2020/3/20時点の結論 / Link 1
5 地雷API | API(プログラミング) 1
5 Amazonアソシエイト・プログラム 1
5 開発 0 1
2024/4/19 1:02 更新