git addコマンドでドライラン(dry run)して対象ファイルを確認する方法
git addコマンドでドライラン(dry run)して対象ファイルを確認するには-nオプションを指定します。
オプションの説明
-n, --dry-run Don’t actually add the file(s), just show if they exist and/or will be ignored.
-nオプションを指定した場合
$ git status On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) deleted: COPYING modified: Makefile modified: README.md modified: SECURITY.md Untracked files: (use "git add ..." to include in what will be committed) test.txt no changes added to commit (use "git add" and/or "git commit -a") $ git add -n *.md add 'README.md' add 'SECURITY.md' $ git status On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) deleted: COPYING modified: Makefile modified: README.md modified: SECURITY.md Untracked files: (use "git add ..." to include in what will be committed) test.txt no changes added to commit (use "git add" and/or "git commit -a")
-nオプションを指定しない場合
$ git status On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) deleted: COPYING modified: Makefile modified: README.md modified: SECURITY.md Untracked files: (use "git add ..." to include in what will be committed) test.txt no changes added to commit (use "git add" and/or "git commit -a") $ git add *.md $ git status On branch master Your branch is up to date with 'origin/master'. Changes to be committed: (use "git restore --staged ..." to unstage) modified: README.md modified: SECURITY.md Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) deleted: COPYING modified: Makefile Untracked files: (use "git add ..." to include in what will be committed) test.txt