4.1.2.commit
Last updated
Was this helpful?
Last updated
Was this helpful?
Working Tree(工作目錄):
Git管理的實體資料夾, 也是實際操作的資料夾(檔案)
Index (系統索引):
存放一堆需要被commit的(異動)文件內容集合, 把檔案加入索引稱 Stage 或 Cache
Repository
是Git存放檔案的位置, 許多commit結點(版本)紀錄於此
git reset就是重置HEAD
--soft:
working tree, Index未改變, 就只是改變repository (commit)
所有的東西仍在準備狀態, 因此可以有另一次送交的機會
1.取消最新一次的commit
git reset --soft HEAD^
2.重新遞交commit
git commit -a -c ORIG_HEAD
mixed: working tree未改變, 改變Index, repository(commit)
--hard
會更改working copy的檔案改回原樣, working tree會被改變, 並重置HEAD
不關心內容
1.取消最新一次的commit
git reset --hard HEAD^
2.將取消掉的commit還原回來
git reset --hard ORIG_HEAD
順序
從commit紀錄中找到發生bug及無bug的commit -> 找出後比較兩個commit間的差異
列出所有的commit
顯示某個commit的內容
比較兩次commit的差異
順序
1.列出原有的commit
git log
2.將修改後的檔案加入修改
git add sample.txt
3.將最新的commit修改為這次的commit
git commit --ammend
順序
1.列出原有的commit
git log
2.取消特定的commit
git revert HEAD
git revert (commit)