git addしようとしたらwarning: adding embedded git repository: server/uketuke/jquery.ripples hint: You’ve added another git repository inside your current

(ここら辺の本を一通り読んで凄いと思ったので紹介、記事は分かりにくいかもしれないので、是非本かって読んでください、基本を徹底するのが良いエンジニアの共通点)

 

 

現状

git addしようとしたら下記のようなエラーが出ました。

$ git add . -A
warning: adding embedded git repository: server/uketuke/jquery.ripples
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> server/uketuke/jquery.ripples
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:   git rm --cached server/uketuke/jquery.ripples
hint: 
hint: See "git help submodule" for more information.
fujisawukenoMBP:Lamplight-Reception hujisawa$ git rm --cached server/uketuke/jquery.ripples
error: the following file has staged content different from both the
file and the HEAD:
    server/uketuke/jquery.ripples
(use -f to force removal)

解決方法

根本的な解決になってないけど、とりあえず

 

上記のエラーはコミットしようとしたディレクトリが、別のgitリポジトリを持っていた場合に出現する。

 

だからrm -rf .git/とかでコミットしたい別のgitリポジトリを持つディレクトリとか

 

ファイルからgitを取り除けばadd&commitできるようになる

Gitで老ける。エンジニアの僕が勧めるGit入門本[2020年]

藤沢瞭介(Ryosuke Hujisawa)
  • りょすけと申します。18歳からプログラミングをはじめ、今はフロントエンドでReactを書いたり、AIの勉強を頑張っています。off.tokyoでは、ハイテクやガジェット、それからプログラミングに関する情報まで、エンジニアに役立つ情報を日々発信しています!

未整理記事