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

GitGit BASH

目次一覧

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

エラー対応


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

 閲覧数:359 投稿日: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

エラー対応

 閲覧数:286 投稿日: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
2026/9/08 19:33 更新
週間人気ページランキング / 9-1 → 9-7
順位 ページタイトル抜粋 アクセス数
1 デザイン カテゴリー 2
2 GitHub への PUSH へ 1回成功したぐらいでは、Git 理解したことには全然ならない | Git BASH(Git) 1
2 次回検証 / 入力順番を間違えたためグダグダになってしまった例 1
2 「ロボットによる操作ではないことを確認してください」と表示されているにも関わらず、確認する方法が案内されている場合は、ブラウザキャッシュを削除する | Twitter Developer(Twitter) 1
2 Twitter API Oauth / Application-only authentication: Oauth2 (bearer token) / Application-user authentication: Oauth 1a (access token for user context) 1
2 リファクタは、開発が一区切りついた段階でなるべく実行した方が良い | Webサービス開発 1
2 6.ローカルリポジトリに、リモートリポジトリを設定する / ローカルリポジトリに設定されている、リモートリポジトリ内容を一覧表示(URLも表示) / ローカルリポジトリ(mainブランチ)(の変更)を送信して、リモートリポジトリ(「origin」上の同名ブランチ)へ反映させる 1
2 キーワード「@4532_hachi」検索結果一覧 1
2 Webサイト制作履歴 | Webサービス開発 1
2 注意点 / 準備編 /理想とするプロジェクト新規作成手順 1
2 「丁寧さ」をどうするの? / 以前作成したhelpを確認してみる / 色々迷う 1
2 SFC(プログラミング) カテゴリー 1
2 鍵に保存されたパスフレーズを変更 / (Windowsならでは)「File name too long」エラー対処 / (Windowsならでは)改行コードを自動変換しないよう設定 1
2 server カテゴリー 1
2 A.データをどこで保存するか? / B.収益をどう見込むか / C.既存サービスが既に存在しているのに、新たに作成する意義はあるか 1
2 Twitter実装記録 / A.Twitter指定キーワード検索 1
2 ログイン 1
2 技術書籍 | プログラミング 1
2 開発 0 1
2026/9/8 5:05 更新