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

Gitのファイルの管理対象

Posted at

はじめに

gitのファイル管理にふくめるか、含めないかを規定するファイルである.gitignoreやその他のフォルダ・ファイルのGitでの管理方法を整理した。
すでに多くの方がまとめてくださっているが、改めて初心者エンジニア目線で整理してみることにした。

.gitignore

Gitのファイル管理(トラッキング)から外したいファイル・ディレクトリを指定することができる。
詳しい書き方、指定の仕方などは以下の@anqooqieさんの記事を参考にして下さい。
https://qiita.com/anqooqie/items/110957797b3d5280c44f

特徴

1.ディレクトリごとに.gitignoreを指定できる
例えば、フロントエンドとバックエンドのフォルダごとに.gitignoreを設定することができる
逆に言えば、.gitignoreは,このファイルが置かれているフォルダより下にしか影響しない

2.特定のフォルダ名、ファイル名の指定だけでなく、ワイルドカード+拡張子のような形で指定もできる

その他の除外設定ができるファイル

  • /.git/info/exclude
    • 個人環境でのみ除外したいファイル(自作メモ、設計や実験の検討など)
    • .gitignoreはチーム全体で除外したいファイル(ログデータなど)を指定するが、個人でのみ除外したいものはこちらで指定
    • 書き方は.gitignoreと同様の指定の仕方ができる

空のディレクトリを除外/特定のディレクトリ内の特定のファイルのみを除外して管理したい

学習済みモデルの保存先としてフォルダのみ作成しておきたい場合などがある。

解決方法
慣例的には.gitkeepというファイル名でファイルを作成しておき、
.gitignoreで、.gitkeepを除外対象からはずす

.gitignore
    !.gitkeep

dataディレクトリ内のその他のファイルはGitの追跡対象から外れるが、gitkeepだけは管理対象となるため、結果的にdataディレクトリが存在する。

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?