LoginSignup
0
0

More than 1 year has passed since last update.

【Git】.gitignoreって難しい Part1 - .gitignoreの作成未経験者が、ある程度の理解できるまで -

Last updated at Posted at 2022-06-15

.gitignoreって?

.gitignore とは、Git による追跡から、特定のディレクトリ・ファイルを除外するための設定を書き込むファイルです。

例えば、node_modules は膨大な量ですし、package.json を持っているので、 npm install または yarn install によって node_module にすべてのパッケージをインストール可能です。
そのため一般的にGitで追跡する必要がなくなります。

どうやって設定するの?

まず、 .gitと同じ階層に移動します。


■ .gitignore ファイルを生成

$ touch .gitignore

■ .gitignore ファイルに設定を記述する

.gitignore
# Nuxt dev/build outputs
.output
.nuxt
# Node dependencies
node_modules
# System files
*.log

こちらはプロジェクトごとに設定されてください。
VSCode、vimエディタでも編集可能です。

ちなみにNuxt.jsでは、公式に用意されているファイルがありますので、今回はこちらを使用させていただいております。
https://v3.nuxtjs.org/guide/directory-structure/gitignore/

■ 確認

$ git ls-files --other --ignored --exclude-standard

こちらのコマンドを叩くと、.gitignore されたディレクトリやファイルが出力されるはずです。

■ 問題
最初に作り忘れていた時に、後から作成する方法は別になってきます。
この記事は後ほど作成しますー

感想

ひゃーーーーーーーー、Gitって色々難しいなーーーー
プログラムが書けるからエンジニア、ではなくこういう所もどんどん成長していきたいね。
最近考え方ががらりと変わってます。w

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