Menyatakan transisi dari satu komit ke komit baru
0. last commit,i.e. HEAD commit
1. Working tree changes, file/directory deletion,adding,modification.
2. The changes are staged in index
3. Staged changes are committed
Tindakan untuk transisi negara
0->1: manual file/directory operation
1->2: git add .
2->3: git commit -m "xxx"
Periksa perbedaan
0->1: git diff
0->2: git diff --cached
0->1, and 0->2: git diff HEAD
last last commit->last commit: git diff HEAD^ HEAD
Kembalikan ke komit terakhir
2->1: git reset
1->0: git checkout . #only for tracked files/directories(actions include modifying/deleting tracked files/directories)
1->0: git clean -fdx #only for untracked files/directories(action includes adding new files/directories)
2->1, and 1->0: git reset --hard HEAD
Setara dengan git clone, tanpa mengunduh ulang apa pun
git reset && git checkout . && git clean -fdx