git addコマンドでUntracked files(未追跡ファイル)を除いてaddする方法
git addコマンドでUntracked files(未追跡ファイル)を除いてaddするには-uオプションを指定します。
オプションの説明
-u, --update Update the index just where it already has an entry matching . This removes as well as modifies index entries to match the working tree, but adds no new files. If no is given when -u option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).
-uオプションを指定した場合
$ 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 -u $ git status On branch master Your branch is up to date with 'origin/master'. Changes to be committed: (use "git restore --staged ..." to unstage) deleted: COPYING modified: Makefile modified: README.md modified: SECURITY.md Untracked files: (use "git add ..." to include in what will be committed) test.txt
-uオプションを指定しない場合
$ 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 . $ git status On branch master Your branch is up to date with 'origin/master'. Changes to be committed: (use "git restore --staged ..." to unstage) deleted: COPYING modified: Makefile modified: README.md modified: SECURITY.md new file: test.txt