LoginSignup
22
22

More than 5 years have passed since last update.

.gitignore 動かないこと

Posted at

現象:

git pushした後、github上に要らないのvendorフォルダ下の全部ファイルがプッシュされてしまいましたこと気づいたんです、その後、.gitignoreに「/vendor/*」を追加したんだけど、
なんか効かない状態です。

原因:

vendorフォルダがすでにrepoにチェックされてしまうので、.gitignoreに「/vendor/*」を記述しても、効けないです。

対策:

git rm -r --cached vendor
.gitignoreに「/vendor/*」を追加

# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
/vendor/*

補足

git rm -r --cached vendorを実行してから、git statusを発行すると、
vendor/下のファイルがUntracked filesとして、表示されました

この方法で、無視されるかとうか検証できる
例:

1:今はクリアです

  demo git:(fully_use_RESTful) git status 
On branch fully_use_RESTful
nothing to commit, working directory clean
  demo git:(fully_use_RESTful) 

2:わざと/log/*をコメントアウトして

#/log/*
!/log/.keep
/tmp
/vendor/*

3:git statusで確認して【log/development.log】が出てしましました

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

    log/development.log

22
22
1

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