Search code examples
gitgitignore

gitignore new file content not working


I have a .htaccess file in a repo and I cloned the repo in my local system, but now the .htaccess file needs to change. So I added .htaccess to .gitignore file. And when I do git status, it still showing .htaccess file modified and will be pushed.

Any help would be appreciated. Thanks


Solution

  • Try following command

    git update-index --assume-unchanged .htaccess
    

    It will tell git to assume that the file won't be changed for repo and won't be pushed.

    To undo this at any time use this command :

    git update-index --no-assume-unchanged .htaccess
    

    Hope this helps.