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 @ 01:41 PM
Fear not the terminal.
Jerrod Blavos said on 01/08 @ 06: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 @ 02: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

* Denotes required fields
(not made public)

May 2012
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    

last.fm

NOW

Grouplove: Never Trust A Happy Song

RECENTLY

Grouplove: Never Trust A Happy Song Grouplove: Never Trust A Happy Song Grouplove: Never Trust A Happy Song Grouplove: Never Trust A Happy Song Friend me on Last.fm - vtupser
top of page
 

where you can find me

RailsConf 2010

Flickr Github Working with Rails Linked In

my twitter tweets

 
Retiring early, just bought 2 shares of FB. #wishfulthinking
May 18, 2012 @ 11:20am
 
follow me