用了一段时间git了,一直有个问题没解决。当做了一些修改时,一般会直接 "git add ." 先将文件staged起来。
但是"git add ."对被删除的内容是无效的,还需要"git rm filename"删除文件,但是git rm命令貌似没有类似"git rm ."的用法(这样可以执行,但意思是删除所有文件),于是,当有比较大量的文件被删除时,一个个的git rm非常麻烦。。我现在基本上都是到gui的git(比如mac的Tower)中全选,批量Stage搞定,但是,命令行下面如何做比较方便呢,难道要自己写个脚本?
It will stage all files that we have not deleted through git rm
There is another one
git commit -a
that can be used. Basically, deleted files will be automatically marked, but it will not work for new filesgit can use glob pattern wildcards. Git also has its own file pattern extension matching method. For example, git rm *.c deletes files ending in .c in the current directory and all subdirectories recursively. git rm *.c will only delete the .c file in the current directory.
I have also encountered the original poster's problem before. I was confused for a long time and had to clear the cache files manually every time.
Baidu went to the original poster today, but couldn't find the answer. Then I happened to encounter a need, so I thought about it and found a way.
1. Clear the files in the cache first.
git rm -r --cached a directory
2. Add all files back to the cache
git add .
git rm * -f deletes all files (including all directories) under the current git project