gitclean - a git clean wrapper
Table of Contents
Last week, I had to make some changes to the code. I was keep on making changes but forgot to add them to git and to take backup. When I am almost done I wanted to commit and before committing I checked the changed files with this.
\\
git status
\\
it listed all the files which have got changed and few other temporary files and compiled binaries, which I don't want to keep in the repository. So I did
\\
git clean -qfxd
\\
That's it. This cleared everything, including my newly added untracked files and all my hardwork went in vain. Then I read about git clean here and got to know what I could have done to avoid this problem. And then I was thinking, if there is a script which would remind me that, the following files will also be removed and only when I say `yes` it would go ahead and clean the repository. So I made this gitclean script. This would collect the status of the files with git status --porcelain and then compare it with the list of extensions specified in the config file. If they match, it would report to the user and ask his consent before beginning to clean.
\\
Github
\\
Github Repository : https://github.com/thefourtheye/gitclean.
\\
Installation
\\
To install this script, please follow these steps
\\
\\
- The first step will download the script from github
- The second step changes the permissions of the file to 544
- The third step installs the script. Basically, it copies itself to the user's home directory and creates the gitclean alias in the
$HOME/.bashrcfile\\
Configuration
Sample Runs
- With no files changed
- With one interesting file [Test.js]
- With one interesting file [Test.js] and a non-empty directory
- With one interesting file [Test.js] and a non-empty directory and a non-interesting file [Test.txt]