Git exclude file if gitignore not works

# Exclude from the management of Git
$ git update-index --skip-worktree path/to/file

# Restore back
$ git update-index --no-skip-worktree path/to/file


# If ignore file not working use this code below before push
$ git update-index --assume-unchanged -- config.php

# for folder
$ git update-index --assume-unchanged -- application/logs/*


# Ignore full directory with nested directory in it
$ git ls-files -z public/uploads/ | xargs -0 git update-index --assume-unchanged

Leave a Reply

Your email address will not be published.