Yenya's World

Sat, 28 Mar 2009

Git Snapshots

In his excellent article Git from the bottom up (PDF warning) John Wiegley writes on page 26 about using git-stash(1) as a way of snapshotting the work in proggress, e.g. from cron(8). He suggest to do git-stash && git-stash apply every hour or so. It is a nice idea, but it has a problem:

It changes the data under your hands, and there is even a short window of time (between the stash and apply), when the local changes temporarily disappear from the working tree. So during this window it is not possible to e.g. open the file with the text editor and expect it to have the contents which has been written to it just several seconds ago.

Can snapshotting be done in Git correctly? Something like "save a current working tree as a new unreferenced commit"? How do you make the snapshots of your work, my dear lazyweb?

Section: /computers (RSS feed) | Permanent link | 4 writebacks

4 replies for this story:

Tomáš Janoušek wrote:

`git stash create' seems to do the job. It creates a commit object, leaves index and tree intact and prints the commit's SHA1, so you just need to save that somewhere (using a tag, maybe).

Milan Zamazal wrote:

I'm not sure what you want to achieve. I usually commit often, any significant change. It's useful for several reasons. If I need to backup a larger amount of work without making a commit, I simply copy the corresponding files or directories somewhere, preferably to a remote site. BTW, AFAIK git-stash ignores new files unless they are staged.

Yenya wrote: Re: Tomáš Janoušek

"Git stash create" is almost the thing I am looking for. The only feature it does not have is storing the reference to the commit object somewhere (and preferably, keeping the reference for several weeks only, like reflog does).

Karel Zak wrote:

Hmm.. long patches are bad patches. Commit often and use a real (incremental) backup solution rather than "git-stash from cron". ;-)

Reply to this story:

 
Name:
URL/Email: [http://... or mailto:you@wherever] (optional)
Title: (optional)
Comments:
Key image: key image (valid for an hour only)
Key value: (to verify you are not a bot)

About:

Yenya's World: Linux and beyond - Yenya's blog.

Links:

RSS feed

Jan "Yenya" Kasprzak

The main page of this blog

Categories:

Archive:

Blog roll:

alphabetically :-)