3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

メモ git管理しているプロジェクトに別のリポジトリをgit cloneしたいとき

Last updated at Posted at 2020-11-21

リモートから新たに何かクローンしたい

既にgit initされているフォルダに別のモジュールをリモートからクローンしてくる場合を考える

$ git clone https://github.com/usr/something

これでクローンされた。
statusを見てみる

$ git status

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    something/

git addすると警告が出る

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

入っている様に見えるが、中身は空!

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   something #この中身が空!

別リポジトリからクローンしてきた.gitを消して下記コマンドで解決

$ rm -rf something/.git
$ git rm -f --cached something
$ git add .
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   something/.env.example
	new file:   something/.gitignore
	new file:   something/LICENSE
	new file:   something/Makefile
	new file:   something/README.md
	new file:   something/db/log/.gitignore
	new file:   something/db/my.cnf
	new file:   something/docker-compose.yml
	new file:   something/php/Dockerfile
	new file:   something/php/php.ini
	new file:   something/web/default.conf
3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?