Note to self: Use git clean sparingly
The other day, I had some merge conflicts to resolve on a project with another team member. Prior to this, I had been developing on the working branch and had created new files. Being lazy, I never added those untracked files in my commit previously, so I jumped right in and did a pull.
Because of the resulting merge conflicts, git loves to leave around .orig files on my system. If you are a neat freak like I am, I hate having extraneous useless files in my file system. Remember, I still had untracked files in my working directory that git had no idea about yet. I decided to continue on and remove the .orig files so git would stop showing them to me.
git clean -f
# I use the -f parameter for a failsafe requireForce
# is set to true in my git config
Unbeknownst to me, doing this wiped out all my new files that I had created. Panicking, as there were quite a few new files, I tried to figure out how to get these back. Doing a reset of the head to a certain hash didn't help one bit. Looking into the reflog had no luck either. Luckily, my previous commit before the pull had some trace of these new files and I decided to popup gitX — an awesome GUI for git those that can't stand terminal output, me included.
Quickly going back through my history, I found the files. Not completely sure how they were still there, but I found them and was able to get them back to a working point.
Now I know that using git clean will also wipe out your untracked-unstashed files.
| September 2010 | ||||||
|---|---|---|---|---|---|---|
| S | M | T | W | T | F | S |
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | ||









333 shared their opinion. ADD YOURS »
Add your opinion here