0

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.

刘奔康
  • 185
  • 1
  • 2
  • 7
  • 1
    Possible 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 Answers1

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

Also see Git Ignore docs

Ben Rhys-Lewis
  • 3,118
  • 8
  • 34
  • 45