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?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
userMod2
  • 8,312
  • 13
  • 63
  • 115

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
  • 27,194
  • 6
  • 32
  • 53