search

Home  >  Q&A  >  body text

php - Git ignore How to not only track local files but not delete remote files?

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. .

大家讲道理大家讲道理2741 days ago1244

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你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

    This

    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 some

    commands 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 donesed

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再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.

    reply
    0
  • Cancelreply