Staging / index.
C-c on the property string first!
execute it first
case $(pwd) in
,*git_lab_1*)
cd ..
rm -rf git_lab_1
mkdir git_lab_1
cd git_lab_1
pwd
ls -al
;;
,*)
echo "You're in a wrong directory pal: $(pwd)."
;;
esac
/Users/allarm/Tmp/git_lab_1 total 0 drwxr-xr-x 2 allarm staff 64 Nov 10 18:11 . drwxr-xr-x 24 allarm staff 768 Nov 10 18:11 ..
echo "Hello world!" > hello.txt
echo "Goodbye world :(" > goodbye.txt
mkdir awesome_dir
echo "I am awesome!" > awesome_dir/awesome.txt
git init
git config user.name "Andrey Che"
git config user.email "andrey@che.org"
git add .
#git commit -m "First commit"
Initialized empty Git repository in /Users/allarm/Tmp/git_lab_1/.git/
Currently, we added a couple of file to staging (or index). Nothing has been commited yet.
Let's check the file tree.
tree .git -I *sample
.git |-- HEAD |-- config |-- description |-- hooks |-- index |-- info | `-- exclude |-- objects | |-- 11 | | `-- dd309e25ce41320f8b55ef3be7d50246a8b4a6 | |-- c1 | | `-- 2fddafdaba3b7b1281f50c9e482ed673f1767c | |-- cd | | `-- 0875583aabe89ee197ea133980a9085d08e497 | |-- info | `-- pack `-- refs |-- heads `-- tags 11 directories, 8 files
The refs
dir is empty.
Now let's get the file objects:
objects=$(find .git/objects -type f | awk -F"/" '{print $3$4}')
for o in $objects
do
echo "$o : $(git cat-file -t $o)"
done
c12fddafdaba3b7b1281f50c9e482ed673f1767c : blob 11dd309e25ce41320f8b55ef3be7d50246a8b4a6 : blob cd0875583aabe89ee197ea133980a9085d08e497 : blob
Let's check what would change after the commit.
git commit -m "First commit"
tree .git -I *sample
[master (root-commit) 55c2ff5] First commit 3 files changed, 3 insertions(+) create mode 100644 awesome_dir/awesome.txt create mode 100644 goodbye.txt create mode 100644 hello.txt .git |-- COMMIT_EDITMSG |-- HEAD |-- config |-- description |-- hooks |-- index |-- info | `-- exclude |-- logs | |-- HEAD | `-- refs | `-- heads | `-- master |-- objects | |-- 11 | | `-- dd309e25ce41320f8b55ef3be7d50246a8b4a6 | |-- 27 | | `-- c68820a14130e9866371d6cb746ca5cbd39864 | |-- 55 | | `-- c2ff56b2d2c3b08c3e5680280a84a69a83a7d9 | |-- c1 | | `-- 2fddafdaba3b7b1281f50c9e482ed673f1767c | |-- cd | | `-- 0875583aabe89ee197ea133980a9085d08e497 | |-- ed | | `-- 557584085e6ecbc79a01adb943fdba7a05f5f0 | |-- info | `-- pack `-- refs |-- heads | `-- master `-- tags 17 directories, 15 files
objects=$(find .git/objects -type f | awk -F"/" '{print $3$4}')
for o in $objects
do
echo "$o : $(git cat-file -t $o)"
done
ed557584085e6ecbc79a01adb943fdba7a05f5f0 : tree c12fddafdaba3b7b1281f50c9e482ed673f1767c : blob 27c68820a14130e9866371d6cb746ca5cbd39864 : tree 11dd309e25ce41320f8b55ef3be7d50246a8b4a6 : blob 55c2ff56b2d2c3b08c3e5680280a84a69a83a7d9 : commit cd0875583aabe89ee197ea133980a9085d08e497 : blob
3 blobs that had been there before the commit remain unchanged. There are 2 new tree objects. One is a pointer to the files in a root directory (and to the awesome_dir
sitting inside this directory) and another one points to the files in awesome_dir
:
objects=$(find .git/objects -type f | awk -F"/" '{print $3$4}')
for o in $objects
do
type=$(git cat-file -t $o)
if [ $type == "tree" ]
then
echo "[ $o : $type ]"
echo
git cat-file -p $o
echo
fi
done
[ ed557584085e6ecbc79a01adb943fdba7a05f5f0 : tree ] 100644 blob 11dd309e25ce41320f8b55ef3be7d50246a8b4a6 awesome.txt [ 27c68820a14130e9866371d6cb746ca5cbd39864 : tree ] 040000 tree ed557584085e6ecbc79a01adb943fdba7a05f5f0 awesome_dir 100644 blob c12fddafdaba3b7b1281f50c9e482ed673f1767c goodbye.txt 100644 blob cd0875583aabe89ee197ea133980a9085d08e497 hello.txt
There's also a new commit object referencing the root tree (27c6
):
objects=$(find .git/objects -type f | awk -F"/" '{print $3$4}')
for o in $objects
do
type=$(git cat-file -t $o)
if [ $type == "commit" ]
then
echo "[ $o : $type ]"
echo
git cat-file -p $o
echo
fi
done
[ 55c2ff56b2d2c3b08c3e5680280a84a69a83a7d9 : commit ] tree 27c68820a14130e9866371d6cb746ca5cbd39864 author Andrey Che <andrey@che.org> 1605003146 +0800 committer Andrey Che <andrey@che.org> 1605003146 +0800 First commit