Usually git ignore will no longer track its own local files, and the remote file will be deleted after push.
My requirement is that local files will no longer be tracked, and remote files will not be deleted. Otherwise, the code in the remote warehouse will be broken. Think about it, how terrible it is that the db.config file is deleted from the warehouse. .
世界只因有你2017-05-25 15:10:28
First of all, local non-tracking and remote warehouse non-deletion cannot be obtained at the same time, because git
is in the form of a snapshot every time it is submitted, rather than submitting several files, so if it is not tracked locally, then This file will be deleted by default when submitting.
Solution: This kind of problem is very common. It is similar to whether node_modules
should submit to the remote repository. You mentioned a sentence--"The code of the remote repository is broken." I need to correct it. Now, it doesn’t mean that the code from the remote warehouse above can be directly run
. Ninety percent of it requires changing something and setting up some environment before it can work< /code>, just like the
node_modules
problem I just mentioned, no one will upload such a large file, only a package.json
file will be uploaded, and the local needs to be based on this Configuration file to configure local information. node_modules
要不要提交远端仓库等相似,你提到了一句话---“远端仓库的代码就坏了”,我需要纠正一下,并不是说git
上面远端仓库的代码拿下来都是可以直接run
的,百分之九十都是要改一些东西,配一些环境才可以work
的,就比如我刚刚说的node_modules
问题,没人会上传这么大的文件,只会上传一个 package.json
file of yours does not need to be modified or submitted unless the entire project really needs to be modified. db.config
文件也是一样的,你远端仓库上可以存一个db.config.default
或者db.config.sample
这样的文件,这里记录的是db.config
文件的所有默认配置,但是每个人本地开发环境需要将db.config.default
或者db.config.sample
复制一份,重命名为db.config
,然后将配置改为自己需要的,很有可能每个开发人员的本地配置都不一样,这时候把db.config
加入.gitignore
,一般来说.default
或者.sample
If you find it troublesome or there are too many configuration files, you can write a script and use somecommands to achieve the effect of modifying all configurations with one click. I usually do this. In the script, turn on debug and adjust php.ini Scanning the interval time for PHP file changes and other tasks have been done
sed
reply0
过去多啦不再A梦2017-05-25 15:10:28
Your needs can be done, but that’s not a problem. The problem lies in the management of configuration files.
I usually do this: different configuration files for different environments, config.xxx. Different environments are distinguished by environment variables or command line parameters or soft links (to the same name, such as config, this file is not placed in the warehouse), and the corresponding configuration files are loaded.