back to list

Note to self: Use git clean sparingly

  January 08, 2010 — written by Chris Sloan | 3 comments »

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.

filed in: Geekery | permalink

333 shared their opinion. ADD YOURS »

Chris said on 01/08 @ 06:41 PM
Fear not the terminal.
Jerrod Blavos said on 01/08 @ 11:07 PM
the -f flag usually means "If you aren't sure, then you with be -f(cussed)" By the way, i might know some people that can write some papers for you.
Paul Hepworth said on 04/28 @ 06:40 AM
I liked being on the other end... "Paul, can you email me a bunch of files?" wink Glad we didn't have to do that afterall.

Add your opinion here

Commenting is not available in this weblog entry.
March 2017
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 31  
top of page
 

where you can find me

RailsConf 2010

Flickr Github Working with Rails Linked In

my twitter tweets

follow me