標籤:style ar color 使用 sp for strong on bs
git stash 可用來暫存當前進行中的工作, 比如想pull 最新代碼, 又不想加新commit, 或者另外一種情況,為了fix 一個緊急的bug, 先stash, 使返回到自己上一個commit, 改完bug之後再stash pop, 繼續原來的工作。
基礎命令:
$git stash
$do some work
$git stash pop
進階:
git stash save "work in progress for foo feature"
當你多次使用’git stash’命令後,你的棧裡將充滿了未提交的代碼,這時候你會對將哪個版本應用回來有些困惑,
’git stash list’ 命令可以將當前的Git棧資訊列印出來,你只需要將找到對應的版本號碼,例如使用’git stash apply [email protected]{1}’就可以將你指定版本號碼為[email protected]{1}的工作取出來,當你將所有的棧都應用回來的時候,可以使用’git stash clear’來將棧清空。
git stash # save uncommitted changes# pull, edit, etc.git stash list # list stashed changes in this gitgit show [email protected]{0} # see the last stash git stash pop # apply last stash and remove it from the listgit stash --help # for more info
git stash: 備份當前的工作區的內容,從最近的一次提交中讀取相關內容,讓工作區保證和上次提交的內容一致。同時,將當前的工作區內容儲存到Git棧中。
git stash pop: 從Git棧中讀取最近一次儲存的內容,恢複工作區的相關內容。由於可能存在多個Stash的內容,所以用棧來管理,pop會從最近的一個stash中讀取內容並恢複。
git stash list: 顯示Git棧內的所有備份,可以利用這個列表來決定從那個地方恢複。
git stash clear: 清空Git棧。此時使用gitg等圖形化工具會發現,原來stash的哪些節點都消失了。
關於Git的stash命令