Sat, 28 Mar 2009
In his excellent article Git from the bottom up (PDF warning)
John Wiegley writes on page 26 about using
as a way of snapshotting the work in proggress, e.g. from
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
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?
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". ;-)