search

Home  >  Q&A  >  body text

Files pushed by Git are set to be ignored and not deleted from the repository

The configuration file is pushed to the remote warehouse for the first time. Since the system environment of each member of the project is different, the configuration content is also different. It needs to be ignored to prevent pushing

Now cancel the tracking through git rm --cached filename, and then write the file to .gitignore to ignore it. It can indeed be ignored, but the change displayed when submitting is 忽略的文件被删除, and the ignored file is indeed ignored after being pushed to the remote warehouse. Deleted

In general, I want to push the file up for the first time and not push it in the future, but I didn’t expect that if I ignore it, it will be deleted directly from the warehouse. Can you please give me some advice on how to achieve this?

ringa_leeringa_lee2851 days ago902

reply all(7)I'll reply

  • 天蓬老师

    天蓬老师2017-05-02 09:47:29

    Using sparse checkoutsparse-checkoutSolved the problem
    Attached reference link link description

    reply
    0
  • PHP中文网

    PHP中文网2017-05-02 09:47:29

    You can try to deceive yourself and pretend you can’t see it. .

    git update-index --assume-unchanged xxx/xxx

    reply
    0
  • PHPz

    PHPz2017-05-02 09:47:29

    In this case, you usually create one config.ini.distfor users to modify

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-02 09:47:29

    I think you don’t actually need to set ignore files in the .gitignore file. Since you don't want to push those files to the remote, but want to keep those files remotely, you can just not add them to the temporary storage area. Specifically, just git add的时候,别把那些文件addjust go in. However, this also has the disadvantage that you may encounter a situation where you cannot switch branches because there are always some modifications that have not been added to the staging area.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-02 09:47:29

    Your idea is very strange. Since you don’t need to worry about it after the first submission, then you don’t need to add it to the .gitignore file. Is your file constantly changing?

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-02 09:47:29

    Just add the file name directly to gitignore, and then generate one online and you’re done. Why do you have to fix git? Didn't understand.

    reply
    0
  • 黄舟

    黄舟2017-05-02 09:47:29

    I have encountered this problem and haven’t found a solution yet. I guess there’s no way

    reply
    0
  • Cancelreply