git 忽略文件
淡淡烟草味
淡淡烟草味 2017-05-02 09:33:19
0
6
559

我刚开始接触git 然后想忽略文件 但是出现了一些我不知道怎么解决的问题
比如,我想忽略html文件
我使用

cat .gitignore
vim .gitignore

然后在.gitignore文件的编辑模式下,写下

#忽略以html结尾的文件
*.html

保存退出

我在看git status的时候,hmtl文件确实是没有了,但确出现了

我需要提交.gitignore文件.是不是我忽略文件的方式有问题

淡淡烟草味
淡淡烟草味

reply all(6)
大家讲道理

1. There is nothing wrong with the way you ignore files
2. .gitignore files can work normally without submitting them
3. Git will only ignore untracked files in the .git library based on .gitignore

If your "new file.html" can be ignored and the "old file.html" that has been submitted is re-modified, then Git will not ignore the latter.

Method:
1. Execute git rm --cached old file.html
2. Execute git commit old file.html -m 'Comment...'

Explanation:
1. Delete the tracked files from the .git library without deleting them locally (if you want to delete them locally, do not add git before the rm command)
2. Submit, and then the files are removed from the .git library. Really deleted

After that, "old file.html" will no longer be tracked

---------------Separating line-----------------

Because the .gitignore file has been submitted, Git has tracked it, and you have modified the .gitignore file again
Then when you check the status with git status, of course it is:

modified: .gitignore 红色标记状态,等待加入add命令暂存下一步提交

Method 1, undo modifications:
Execute git checkout -- ".gitignore"

Method 2: Submit the modification to the .git library and let Git track it:
Execute git add .gitignore
Execute git commit .gitignore -m 'Comment...'

黄舟

Modified.gitignore, it needs to be submitted normally, and there is no problem

小葫芦

If gitignore does not appear to be modified, then the file you used to ignore the file has been ignored. Isn’t it very messy?

Peter_Zhu

Did you not commit? . . .gitignore generally requires commit

仅有的幸福

If you modify it, it counts as a modification and you have to commit it

Ty80

.gitignore Submit

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!