Remove all git files from a directory?

前端 未结 7 1636
不思量自难忘°
不思量自难忘° 2021-01-30 12:17

I have a folder under version control. I want to make a copy of it to send around, but don\'t want to include all the .git directories and the files underneath it.

Is

7条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 12:54

    ls | xargs find 2>/dev/null | egrep /\.git$ | xargs rm -rf

    This command (and it is just one command) will recursively remove .git directories (and files) that are in a directory without deleting the top-level git repo, which is handy if you want to commit all of your files without managing any submodules.

    find 2>/dev/null | egrep /\.git$ | xargs rm -rf

    This command will do the same thing, but will also delete the .git folder from the top-level directory.

提交回复
热议问题