git筆記
git的三個階段
working tree:就是你所工作在的目錄,每當你在程式碼中進行了修改,working tree的狀態就改變了。
index file:是索引檔案,它是連線working tree和commit的橋樑,每當我們使用git-add命令來登記後,index file的內容就改變了,此時index file就和working tree同步了。
commit:是最後的階段,只有commit了,我們的程式碼才真正進入了git倉庫。我們使用git commit就是將index file裡的內容提交到commit中。
git diff的使用
git diff:是檢視working tree與index file的差別的。
git diff –cached:是檢視index file與commit的差別的。
git diff HEAD:是檢視working tree和commit的差別的。(你一定沒有忘記,HEAD代表的是最近的一次commit的資訊)
git add回撤
git reset HEAD:回撤所有檔案的add
git reset HEAD 目錄檔案:回撤某個檔案的add:
git commit回撤
git reset –soft commit_id:只回撤git commit,git add依然生效,修改的檔案存在
git reset –mixed commit_id:回撤git commit和git add,修改的檔案存在
git reset –hard commit_id:回撤git commit和git add,修改的檔案也不存在了
修改commit備註
git commit –amend