用了一段时间git了,一直有个问题没解决。当做了一些修改时,一般会直接 "git add ." 先将文件staged起来。
但是"git add ."对被删除的内容是无效的,还需要"git rm filename"删除文件,但是git rm命令貌似没有类似"git rm ."的用法(这样可以执行,但意思是删除所有文件),于是,当有比较大量的文件被删除时,一个个的git rm非常麻烦。。我现在基本上都是到gui的git(比如mac的Tower)中全选,批量Stage搞定,但是,命令行下面如何做比较方便呢,难道要自己写个脚本?
PHP中文网2017-04-21 10:59:25
git add -A
It will stage all files that we have not deleted through git rm
阿神2017-04-21 10:59:25
There is another onegit commit -a
that can be used. Basically, deleted files will be automatically marked, but it will not work for new files
-a, --all ____ Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected.
伊谢尔伦2017-04-21 10:59:25
git 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.
高洛峰2017-04-21 10:59:25
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 .
ringa_lee2017-04-21 10:59:25
git rm * -f deletes all files (including all directories) under the current git project