Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
168 views
in Technique[技术] by (71.8m points)

git - How to stop tracking a file without removing it from repo

I have a config file which I want to keep on the remote repository, but I don't want to track its changes on my computer. Adding it to .gitignore doesn't do the trick.

The reason I don't want to track changes is because it's supposed to differ between computers depending on their environment.

question from:https://stackoverflow.com/questions/7072213/how-to-stop-tracking-a-file-without-removing-it-from-repo

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

1 Reply

0 votes
by (71.8m points)

If that's the case then you shouldn't have the file versioned at all; you should version a template of the file. For example, if the configuration file is foo/config.txt then you should have a versioned foo/config.txt.template in the repository with example (or blank) configuration settings. foo/config.txt should not be in the repository at all, and should be ignored with .gitignore.

Then, in a new clone, you just copy foo/config.txt.template to foo/config.txt and alter the settings as appropriate.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...