back to list

Note to self: Use git clean sparingly

  January 08, 2010 — written by Chris Sloan | 2 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

22 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.

Add your opinion here

* Denotes required fields
(not made public)

March 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 31      

last.fm

NOW

Cute Is What We Aim For:

RECENTLY

My Chemical Romance: Three Cheers for Sweet Revenge All Time Low: So Wrong, It's Right Rise Against: The Sufferer & The Witness The Red Jumpsuit Apparatus: Don't You Fake It Friend me on Last.fm - vtupser
top of page
 

where you can find me

Flickr Github Working with Rails Linked In

my twitter tweets

 
Looks like it's going to be a house of estrogen. We are having a girl!
March 09, 2010 @ 9:36am
 
follow me