Reputation: 6017
I have two branches to my project, master and test branches . when I'm at branch test, I edited the file .gitignore I added vendor/* . but for some reason when I do git push origin test:master it still push files in vendor. is there any way to flush the cache or something like that to make sure it is working ?
Thanks in advance
Upvotes: 2
Views: 3025
Reputation: 121702
My guess here is that you had files tracked by git in your vendor
directory prior to filling .gitignore
.
In which case the behavior you see is normal: the git index knows about these files and tracks their contents. If you fill your .gitignore after git tracks the file, it is too late, it will only ignore files you add from this point on.
What you need to do is unreference these files (or "untrack"), so that the index does not know about them anymore -- but without deleting them. For this, use the --cached
option of git rm
:
git rm -r --cached vendor
Then commit the result. From now on, and as you have filled .gitignore, the vendor
directory will be ignored.
Note that you will have to repeat this operation for each and every branch in which you have files tracked in this directory.
And finally, there is a more destructive way, and as such very dangerous: git filter-branch
. But you want to do that as a last resort, and only if you really need this.
Upvotes: 9