git addコマンドでIgnored files(無視ファイル)をaddする方法
git addコマンドでIgnored files(無視ファイル)をaddするには-fオプションを指定します。
オプションの説明
-f, --force Allow adding otherwise ignored files.
-fオプションを指定した場合
$ git status --ignored On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: README.md Untracked files: (use "git add ..." to include in what will be committed) test.txt Ignored files: (use "git add -f ..." to include in what will be committed) test.obj no changes added to commit (use "git add" and/or "git commit -a") $ git add -f test.obj $ git status --ignored On branch master Your branch is up to date with 'origin/master'. Changes to be committed: (use "git restore --staged ..." to unstage) new file: test.obj Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: README.md Untracked files: (use "git add ..." to include in what will be committed) test.txt
-fオプションを指定しない場合
$ git status --ignored On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: README.md Untracked files: (use "git add ..." to include in what will be committed) test.txt Ignored files: (use "git add -f ..." to include in what will be committed) test.obj no changes added to commit (use "git add" and/or "git commit -a") $ git add test.obj The following paths are ignored by one of your .gitignore files: test.obj hint: Use -f if you really want to add them. hint: Turn this message off by running hint: "git config advice.addIgnoredFile false" $ git status --ignored On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: README.md Untracked files: (use "git add ..." to include in what will be committed) test.txt Ignored files: (use "git add -f ..." to include in what will be committed) test.obj no changes added to commit (use "git add" and/or "git commit -a")