08 July 2009

Atomic git

As I wrote in git-pull-mishap-and-git-clean, the problem with git is that, operations are non-atomic. For example, if a git-pull is interrupted, or fails due to lack of disk space or network problem, the resulting repository will be in an in between state. This is problematic. It would be nice if git operations are atomic, in this sense.

A solution could be to have the git repository inside another git repository. For example, have the linux-2.6.git repo inside another git repo, say git-o-git. When you do a pull in linux-2.6.git, and if it succeeds do a `git commit -a` in the outer git-o-git. If it fails for some reason, one can go back to previous version of linux-2.6.git repo by doing a `git clean -d -f` and `git checkout -f` in the outer git-o-git.

It should be possible to add wrapper scripts to `git` and do this auto magically. May be it could be called as git WC, as it is built on top of git porcelain, which is built on top of git plumbing commands. ;-)

Has anyone tried this already?

2 comments:

Ankit said...

Um run git-fetch, and then merge?

Nikanth Karthikesan said...

@ankit I don't think that will work.. Coz when the pull failed, I don't think even git merge would have worked.. But I didn't try it. Also git fetch/merge can also be interrupted in between? If running them separately would work, but git pull won't sounds like a bug in git-pull.