ioannis ioannis - 1 year ago 84
Git Question

How to remove only files and ignore subfolders on GIT

I want to be able to remove all the files in my local folder and in github, but I have a sub folder that I don't want to touch.

How do I delete all the files while ignoring the sub folder?

Answer Source

Commit and push the results of

git rm -r \*
git read-tree -u --prefix=path/to/it/ @:path/to/it

If you want to preserve your indexed state, insert a x=`git write-tree` above and sub in $x for the @.

Since that's going to kill your .gitignores you can make an untracked one containing


and then git clean -df will wipe all the untracked files except those in that path.