Friday, August 28, 2009

Using Git Stash as a Snapshotter

I use git stash to snapshot my work.

I even use it to snapshot my home directory. I have a cron job that periodically does, basically, this:
git stash
git apply
to squirrel away any work I haven't checked in yet.

Basically.

Until today, it did exactly that, but a few days ago, I started having a Makefile change get undone. My old version kept coming back up like bad Mexican food. Hmm.

The bad (old) version was in my stash. What would happen was that git stash would run, figure out I had no recent changes, and do nothing. Then, git apply would run, and restore the last un-checked-in code in the stash (my bad Makefile).

Hah.

Now, the code says this:
git stash | grep -q 'No local changes to save' ||
git stash apply

2 comments:

Unknown said...

Why was it not stashing the altered Makefile?

Viagra on line pharmacy said...

Do you dislike Mexican food?, I think that it is the best food ever. Specially burritos.