git ignore files
淡淡烟草味
淡淡烟草味 2017-05-02 09:33:19
0
6
609

I just started to use git and I want to ignore files, but there are some problems that I don’t know how to solve
For example, I want to ignore html files
I use

cat .gitignore
vim .gitignore

Then in the edit mode of the .gitignore file, write

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

Save and exit

When I looked at git status, the hmtl file was indeed gone, but it did appear

I need to submit the .gitignore file. Is there something wrong with the way I ignore the file?

淡淡烟草味
淡淡烟草味

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