LoginSignup
0
0

More than 3 years have passed since last update.

エラー:warning: adding embedded git repository:

Posted at

エラー

背景:
1、既にgitにpushしたリポジトリB(最新のもの)にあります。リポジトリBは他の方で作成したもの。現時点は自分のローカルにはないです。
2、既にgitにpushしたリポジトリA(過去のもの)にあります。リポジトリAは自分で作成したもの。現時点は自分のローカルにあります。
3、リポジトリBにリポジトリAのコードを取り込みたいです。
4、ローカルで $ git clone リポジトリB でリポジトリBをcloneしました。
5、ローカルで リポジトリAを リポジトリBのディレクトリの下にコピーしました。
6、リポジトリBのディレクトリで $ git add .  を実行する時に、下記のエラーが発生した。

$ git add .
warning: adding embedded git repository: リポジトリ名
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> リポジトリ名
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:     git rm --cached リポジトリ名
hint: 
hint: See "git help submodule" for more information.

原因

原因:cloneしたリポジトリBはリポジトリAのものを取り込んできていました。

解決策

色々試したが、下記の通りにうまくできました。あまり技術的にならないですが、、(1~4は上記の背景と同じ内容です)

1、既にgitにpushしたリポジトリB(最新のもの)にあります。リポジトリBは他の方で作成したもの。現時点は自分のローカルにはないです。
2、既にgitにpushしたリポジトリA(過去のもの)にあります。リポジトリAは自分で作成したもの。現時点は自分のローカルにあります。
3、リポジトリBにリポジトリAのコードを取り込みたいです。
4、ローカルで $ git clone リポジトリB でリポジトリBをcloneします。
5、gitにあるリポジトリAはローカルでリポジトリBのディレクトリに直接のコピーではなく、リポジトリAをgitからzip fileの形でリポジトリBのディレクトリにdownloadしてください。
6、downloadしたリポジトリAを展開します。zip fileを削除します。
7、再び $ git add . を実行すれば、うまくできました!

参考

git add .で警告。warning: adding embedded git repository: を参考しました!

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