0

I have my sitemap.xml file that I want to leave on the repository (as it is continually updated) however ignore it from any future code commits (as I don't want it to be overwritten).

So to do this - from my reading I need to:

  1. add the file path into .gitignore
  2. As it was committed initially into the repo I need to remove it from being a tracked file so: git rm --cached <file>

However will step also remove from the repo? How do I therefore handle this?

Flimzy
  • 68,325
  • 15
  • 126
  • 165
userMod2
  • 7,060
  • 12
  • 50
  • 98

1 Answers1

0

One possible solution is to add git reset HEAD -- sitemap.xml in pre-commit hook. This hook can be bypassed via -n when git commit if necessary. And in the server side, a hook is needed to reject any commit that includes changes of sitemap.xml.

But I think there are better solutions. This one needs every developer to be aware not to commit the changes of sitemap.xml.

ElpieKay
  • 22,398
  • 5
  • 27
  • 44