问题
I would feel much more comfortable using git clean if I knew I could undo the deletion in case something goes wrong.
Does it support Recycle Bin in any way, shape or form? If no, are there any workarounds that anyone knows of, such as an external tool using git clean -n
to print out the files, and then moving them to Recycle Bin?
回答1:
Put recycle.exe into your %PATH%
Run git config --global alias.recycle !git_recycle.sh
Put git_recycle.sh in your %PATH%
:
#!/bin/bash
cd ${GIT_PREFIX:-.}
git clean -xdfn "$@" | sed 's/Would remove //' | xargs -d \\n --no-run-if-empty recycle
回答2:
No, unfortunately!! git doesn't have this privilege. Whatever gone is gone!!
git clean -fdxn
Will do a dry run, and show you what files would be deleted if you ran
And one more thing, that if you have added files and somehow deleted those files. In this case, you can restore these files by using below command:
'git fsck --lost-found'
It's worth a try, but don't get your hopes up too much.
回答3:
No.
If you're worried about losing files, you a "dry run" is really the only viable option:
git clean -n
or equivalently
git clean --dry-run
Git has no knowledge of the underlying desktop environment, and probably never will.
Git GUIs are capable of showing you these files, but why on earth would you want to move them to the recycle bin in the first place? Just think about what you're doing before removing files.
Alternatively, add the files to a seperate branch in your repository, although that probably defeats the purpose of deleting them in the first place.
来源:https://stackoverflow.com/questions/24671650/does-git-clean-support-moving-to-recycle-bin