Using Git to keep different versions of a file locally vs. in the master repository

假装没事ソ 提交于 2019-12-03 13:24:25

I solved my own problem. I actually need this:

git update-index --assume-unchanged <filename>

Assuming the .gitignore and config.php files being specified as above in my question, here's the complete workflow:

  1. git update-index --assume-unchanged application/config.php
  2. git add -A
  3. git commit -m 'now config.php will be ignored'
  4. git push origin master

Now http://localhost will remain in the config.php on my local copy of the repo and http://my-site.com will be preserved in the config.php in my master repo.

You need to have config.php in your .gitignore file.

If, however, you've actually added config.php to your repo, you'll need to git rm it and then commit, and then recreate it (or you can make a copy and then copy back).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!