How to add .gitignore
file after already push my project? I'm a git starter. Recently I pushed my Intellij Project to github, then I want to add .gitignore
file to shrink my project.
Asked
Active
Viewed 800 times
0

刘奔康
- 185
- 1
- 2
- 7
-
1Possible duplicate of [How to create .gitignore file](http://stackoverflow.com/questions/10744305/how-to-create-gitignore-file) – Ivan Leonenko Apr 13 '16 at 07:48
-
@IvanLeonenko i kow how to create `.gitignore` file . i just want to know could i add my `.gitignore` file after i already push my project to remote repo – 刘奔康 Apr 13 '16 at 08:26
-
http://stackoverflow.com/questions/1470572/gitignore-ignore-any-bin-directory – 刘奔康 May 24 '16 at 02:11
1 Answers
1
You cannot ignore a file once its been committed. You need to use git rm
to remove the files from the repo and then re-commit with them added to the git ignore file.
Eg. I could remove all .htaccess files like:
git rm -r .htaccess

Ben Rhys-Lewis
- 3,118
- 8
- 34
- 45
-
-
Yes exactly, just don't forgot to do the .gitignore file first. Also you could add --cached to rm to leave a cached version there in the history. Good luck! – Ben Rhys-Lewis Apr 13 '16 at 08:17