user2291590 user2291590 - 1 year ago 42
Git Question

Building git commit objects with git hash-object?

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?

Answer Source

Here's a complete and working example of a script that creates a commit object

Just take care to update the SHA1s according to the output you will receive

mkdir proj
cd proj
git init
touch emptyfile
git hash-object -w emptyfile

echo -e "100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\tempfile" | git mktree

echo -e "yourname\[email protected]\n2013 12:20:15 +0200\ncommittername\[email protected]\n2013 10:13:15 +0200" | git commit-tree 00dc1fe163c2450916856ccbe7820c5b0e066257

git update-ref refs/heads/master 2abbdc253583b9820a372c3758b2bcdda0bccca9

git log --oneline
2abbdc2 yourname [email protected] 2013 12:20:15 +0200 committername [email protected] 2013 10:13:15 +0200
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download