4b825dc642cb6eb9a060e54bf8d69288fbee4904

4b825dc642cb6eb9a060e54bf8d69288fbee4904 is a special hash value in git which denotes an empty tree. And it does not change from repo to repo. This opens way to some neat tricks, but how the hell would one remember this value? You don’t need to.

Colin Schimmelfing:

In both of the links that mentioned the special hash, it looks like there is another way to find the magic value, a little faster:

> git hash-object -t tree –stdin < /dev/null 4b825dc642cb6eb9a060e54bf8d69288fbee4904

Thus you get the hash of the ‘null’ tree.

The author of the post mentions about changing/diff-ing the first commit using this, but remember that since git 1.7.12 or so you have this awesome –root flag for git-rebase which does wonders in this particularly intimidating situation.

So, if you want to amend the initial commit or add one after some commits (humans forget), you can just:

git rebase -i –root

Now just do whatever you want in the editor window that pops up. Anything’s possible with git-rebase.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply