Context:
- working on a large project with thousands of files
- project is built using gradle -- build process is not documented; several files are generated and spread across a number of directories
- generated files shouldn't be added to git
- project has no clean task -- once built, generated files must be removed manually
Is there a way to undo the state of the project after build using git? only a subset of the output files is of interest and the others can be ignored but, as it stands, these files are not easy to find.
Can the state after build be reverted to the clean state (after clone)?
One solution would be to add the generated files to a separate branch and work on that. Once built, the project is too large to be pushed to the repo.
Is there another way?
Run:
git clean -d . -X -f
where
-d .
tells git to recur into all directories starting from root (that has the .git dir)-X
tells git to remove all ignored files-f
just delete everything and don't prompt
CodePudding user response:
What you're looking for is git clean.
Cleans the working tree by recursively removing files that are not under version control, starting from the current directory.
Don't forget to look at the documentation to know what flags to use. There is even a dry-run
to test before removing things you didn't want to be removed.