給大家分享幾個git命令:
git stash 暫存工作目錄的修改
git stash list 查看暫存列表
git stash apply 恢復暫存內容并保持最近一次暫存記錄,如果有多個暫存記錄,想恢復指定的暫存記錄,可以使用git stash apply stash@{},其中是git stash list中顯示的暫存記錄索引。例如,要恢復stash@{1}中的內容,可以使用git stash apply stash@{1}。
這種方式恢復暫存內容后,暫存記錄仍然存在,下次使用git stash list時還能看到該記錄。
git stash pop 使用git stash pop命令來恢復最近一次暫存的內容并同時刪除暫存記錄。和git stash apply一樣,如果想恢復指定的暫存記錄并刪除它,可以使用git stash pop stash@{}。例如,要恢復并刪除stash@{2}中的內容,可以使用git stash pop stash@{2}。
注意,在恢復暫存內容時,可能會出現合并沖突的情況。如果出現沖突,需要手動解決沖突,就像解決普通的git merge或git rebase過程中出現的沖突一樣。解決沖突后,需要使用git add命令將解決沖突后的文件添加到暫存區,然后可以繼續執行git stash apply或git stash pop命令來完成恢復操作。