Reference: https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified#The-Workflow
Set up watcher for working directory tree - watch -n 1 -t show-working-dir
#!/bin/bash
set -e
echo "Working Dir"
echo "sandbox"
echo ""
for file in $(ls); do
echo " $file : $(cat $file)"
done
Set up watcher for index tree - watch -n 1 -t show-stage
#!/bin/bash
set -e
echo "Stage/Index"
echo "next commit snapshot"
echo ""
while read -r line; do
filename=$(echo "$line" | cut -d ' ' -f 2)
sha=$(echo "$line" | cut -d ' ' -f 2)
content=$(git cat-file -p $sha)
echo "$sha $filename : $content"
done <<< "$(git ls-files --abbrev -s)"
Set up watcher for head tree - watch -n 1 -t show-head
#!/bin/bash
set -e
echo "Head"
echo "last commit snapshot"
echo ""
while read -r line; do
filename=$(echo "$line" | cut -d ' ' -f 2)
sha=$(echo "$line" | cut -d ' ' -f 3 | head -c 7)
content=$(git cat-file -p $sha)
echo "$sha $filename : $content"
done <<< "$(git cat-file -p head^{tree})"