Building git commit objects with git hash-object?
git
Solution
Here's a complete and working example of a script that creates a `commit` object without ever running `git commit`:
mkdir project
cd project
git init
hash=`echo -n "" | git hash-object -w --stdin`
tree=`echo -e "100644 blob ${hash}\temptyfile" | git mktree`
commit=`echo -e "yourname\nyour@email.com\n2013 12:20:15 +0200\ncommittername\ncommitter@email.com\n2013 10:13:15 +0200" | git commit-tree ${tree}`
git update-ref refs/heads/master ${commit}
To verify that the script created a commit containing an empty file, run:
git checkout --
git log --oneline
#2abbdc2 yourname your@email.com 2013 12:20:15 +0200 committername committer@email.com
Edit: fixed and improved
Problem
How can i manually build git commit objects using git hash-object? I now it works with blobs, and its documentation says it can build different objects by using -t but how do you build a commit with that?