Git已推送的文件设置忽略且不从仓库删除
ringa_lee
ringa_lee 2017-05-02 09:45:29
0
7
791

第一次推送到远程仓库的配置文件,之后因项目每个成员的系统环境不同,配置的内容也不同,需要忽略它以防止推送

现在通过git rm --cached filename取消跟踪,然后把文件写入.gitignore中忽略,的确是能够忽略,但是提交的时候显示的变动是忽略的文件被删除,并且推送到远程仓库后被忽略的文件果然被删除了

总的来说就是想第一次推送把文件推送上去, 以后就都不推送, 但没想到忽略的话是直接从仓库删除, 请各位指点下有何方法能实现?

ringa_lee
ringa_lee

ringa_lee

reply all(7)
Peter_Zhu

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

Ty80

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

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

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

伊谢尔伦

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.

滿天的星座

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?

世界只因有你

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.

黄舟

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!