Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
241 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...