In some cases, we may want a clean directory, for example, my source code has all been submitted to the server's repository, the local source code I would like to delete, but there are some of the energy code directory of our own configuration, data and other files, these files are not version-controlled, If the entire source directory is deleted, these files will be deleted together! If you want a file of version control (tracked files) in a git source directory on your local hard disk, leave the file without version control (untracker files), you can use the following command:
git ls-files | xargs rm
After running the above instruction, manually delete the. Git directory and you will get a clean, versioned directory.
The above instruction has a disadvantage, that is, the empty directory will be left, not deleted, can be deleted by the following command:
For /F "tokens=*" %a in (' dir/b/ad/s directory path ^|sort/r ') do Rd "%a" /q 2>nul
The above instructions are Windows batch instructions, Linux do it yourself.
In fact, there is one of the simplest way to do this: just use git delete command to delete the source Coogan directory! But do not submit on the line, and in this way, the original source directory must not be used for source control, you must re-open a new directory check source. For SVN you can use this command: The SVN delete source directory is a clean version of the file is not versioned, if you have uncommitted changes, you will also be prompted to submit before you can delete ~
To delete a version-controlled file from the local git repository