简体   繁体   中英

.gitignore for file extension( ~) not working

I want to ignore all the files that ends with ~.

My .gitignore fille is

*~

I have placed .gitignore file as below.

sci2c| |2.3.1 |various files and folders |.gitignore

Its not ignoring the files thats ends with ~ in all directories.

Please help.

*~.*应该适用于任何扩展名上的所有此类文件。

If the file is already added in to repository then you need to remove them. Git thinks of its data more like a set of snapshots of a miniature filesystem. Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesn't store the file again, just a link to the previous identical file it has already stored. Git thinks about its data more like a stream of snapshots. So you need to remove the already added files then

git rm --cached file-1 file-2..... file-n

Then the files listed in gitignore will work as expected. Check the notes section in the Git Documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM