Last active
July 20, 2016 16:11
-
-
Save henrahmagix/f0ca62a7d95f682d6582936d1bdfe816 to your computer and use it in GitHub Desktop.
Git Presentation Demo: tree hashes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# More info at http://unix.stackexchange.com/questions/165369/whats-the-difference-between-commit-hash-parent-hash-and-tree-hash-in-gi | |
# Make two git repositories with the same first commit and compare logs | |
for dir in {a,b}; do | |
mkdir $dir | |
( | |
cd $dir | |
( | |
git init | |
echo 'foo' > foo | |
git add foo | |
git commit --message 'Add foo' | |
) &>/dev/null | |
git log --pretty=oneline | |
) | |
done | |
# Make one commit to a, and the same to b but with an empty commit before it | |
( | |
cd a | |
( | |
git commit --allow-empty --message 'Empty' | |
git commit --allow-empty --message 'Empty' | |
echo 'bar' >> foo | |
git diff | |
git commit --all --message 'Add bar to foo' | |
) &>/dev/null | |
git log --pretty=oneline | |
) | |
( | |
cd b | |
( | |
git commit --allow-empty --message 'Empty' | |
git commit --allow-empty --message 'Empty again' | |
echo 'bar' >> foo | |
git diff | |
git commit --all --message 'Add bar to foo' | |
) &>/dev/null | |
git log --pretty=oneline | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment