1
0

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 5 years have passed since last update.

管理したいディレクトリの親ディレクトリでgit initしちゃったら?

Posted at

違う、そうじゃない

突然アイデアが閃くことってありますよね。
早速新しいプロジェクトを作って開発しよう。
作ったらgit initもしておかないとね。

ec2-user:~/environment $ rails new circle-list
      create  
      create  README.md
    :
   (中略)
    :
* bin/rake: spring inserted
* bin/rails: spring inserted
ec2-user:~/environment $ git init
Initialized empty Git repository in /home/ec2-user/environment/.git/
ec2-user:~/environment (master) $

よーし、出来………………あっ
masterと誇らしげに表示されているそこ、親ディレクトリ。

.gitをセンターに入れてrm -rf

git initしたディレクトリには「.git」というディレクトリが出来ます。
ドット始まりなので普通のlsでは見えないので、詳らかにしてくれる-aオプションを使いましょう。

ec2-user:~/environment (master) $ ls -la
total 48
drwxr-xr-x 11 ec2-user ec2-user 4096 Feb 16 13:58 .
drwx------ 13 ec2-user ec2-user 4096 Feb 16 13:44 ..
drwxr-xr-x  3 ec2-user ec2-user 4096 Oct 12 13:05 .c9
drwxrwxr-x 14 ec2-user ec2-user 4096 Feb 16 13:57 circle-list
drwxrwxr-x  7 ec2-user ec2-user 4096 Feb 16 13:58 .git

いますね。
こいつを消せばgitの管理下から外れるので、サクっと消してしまいましょう。
打ってはいけないあのコマンドを打ちます。

ec2-user:~/environment (master) $ rm -rf .git
ec2-user:~/environment $

やったぜ!
本来管理下に置きたかった開発用ディレクトリにある.gitも同じように消去し、そこでgit initしましょう。

ec2-user:~/environment $ cd circle-list/
ec2-user:~/environment/circle-list (master) $ ls
app  config     db       Gemfile.lock  log           public    README.md  test  vendor
bin  config.ru  Gemfile  lib           package.json  Rakefile  storage    tmp
ec2-user:~/environment/circle-list (master) $ rm -rf .git
ec2-user:~/environment/circle-list $ git init
Initialized empty Git repository in /home/ec2-user/environment/circle-list/.git/
ec2-user:~/environment/circle-list (master) $ 

よしよし、これで開発できますね。
ここからgithubにつなげたい方はこちらをどうぞ

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?