6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

途中から .gitignore が言うことを効かない時

Posted at

あるある

結構コミットのスタックがたまってから、途中から「やっぱりignoreしたい」となって、.gitignoreをいじってみても、うまく無視されて無いときがあります。僕だけか...?

適切解?

そういう時はgitignoreを編集後、以下のようにgit rmしてやると適用されるようです(git rm --cachedの場合もあります)

$ git rm want-to-ignore-file
$ git commit -m '消しまっせ〜'

注意

以下のように、一回全部git rm -rしなさい、ってやり方もありますが、この記事中でも言及されているように、一回全部消してからもう一回全部addする、という結構強引なやり方です。

$ git rm -r --cached
$ git add .
$ git commit -m "無理矢理でっせ〜"

version control - Ignore files that have already been committed to a Git repository - Stack Overflow
http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository

See Also

.gitignore does not work [duplicate]
http://stackoverflow.com/questions/6380196/gitignore-does-not-work

6
6
2

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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?