简体   繁体   中英

How to remove all git file except .gitignore

I want to remove all git related files in project except .gitignore file. The commands I found about git remove will remove everything, but most of the time I still need gitignore

How would you do that?

rm -rf .git

这将删除除gitignore以外的所有git文件

You can set a environment in order to ignore special file patterns for the *

For example:

GLOBIGNORE='.git*'
git rm *

so it won't remove any files that starts with .git

More info on GLOBIGNORE


However, if you want to ignore every dot file you can have a look at dotglob

# set dotglob
shopt -s dotglob

git rm *

# unset dotglob
shopt -u dotglob

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