LoginSignup
9
7

More than 5 years have passed since last update.

[注意] Vue CLIは勝手にgit initしてしまう時がある

Posted at

勝手にgit initする条件

gitで管理されていないディレクトリでオプションを付けずにvue create NEW-VUE-APPをすると
NEW-VUE-APP生成中に勝手にgit initしてしまうそうです。(バージョン3.5.5時点)

parent              <- ここだけでgit管理したいのに
├── server/
└── NEW-VUE-APP/    <- なぜか生成時からgit管理されている

勝手にgit initされたら困る場合は

  • 事前にparentディレクトリで git init しておく
  • Vue CLIの公式ドキュメントにある以下のオプションでコントロールする (vue create -n NEW-VUE-APPでgit initを回避)
  -g, --git [message|false]       Force / skip git initialization, optionally specify initial commit message
  -n, --no-git                    Skip git initialization

所感

アプリを自動生成するツールとしてはオプションを付けた時だけgit initするほうが自然だと、私は思います。
なので私のように罠にはまる人が少なからずいるだろうなと思ってこの記事を書きました。
公式ドキュメントを読むのは大事ですね・・

以下のissueの結果、現在の仕様になっているようです。(以前は問答無用でgit initしていたようです)
https://github.com/vuejs/vue-cli/issues/967

9
7
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
9
7