1
0

More than 1 year has passed since last update.

【Git】空のディレクトリをリポジトリに追加する方法

Last updated at Posted at 2021-12-25

方法

以下のファイルをディレクトリに追加する。

.gitkeep
$ touch test/.gitkeep
$ git status
On branch main
Your branch is up to date with 'origin/main'.

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

    test/

nothing added to commit but untracked files present (use "git add" to track)

空のディレクトリを作成しただけだと、差分として認識されない。

$ mkdir test
$ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

補足

この方法は、公式ドキュメントに書かれていないので、お作法的な感じなのかな。ディレクトリ内にファイルがあることが重要なので、.hogeでも良いんだと思います。

参考

【改訂新版】Gitポケットリファレンス 岡本 隆史
https://www.amazon.co.jp/dp/4774185930

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