1. 程式人生 > >在git命令列下檢視git stash裡面檔案的內容

在git命令列下檢視git stash裡面檔案的內容

在使用git的時候往往會儲存一些東西,在儲存的時候使用的就是git stash,強大的git使得儲存修改和恢復修改變的很容易,但有時候時間久了不記得stash裡面的內容是什麼了,通過在stackflow裡面查詢,找到了一個好的方法。其網址是:

當利用git stash pop彈出來會有些耗費時間,這時可以使用git stash show來檢視stash裡面儲存的內容。

在git bash上可以使用git --help stash來檢視git stash命令的用法,當在stash後加show時,官方給出的介紹如下:

show [<stash>]

Show the changes recorded in the stash as a diff between the stashed state and its original parent. When no <stash>

 is given, shows the latest one. By default, the command shows the diffstat, but it will accept any format known to git diff(e.g., git stash show -p [email protected]{1} to view the second most recent stash in patch form). You can use stash.showStat and/or stash.showPatch config variables to change the default behavior.

翻譯如下:顯示修改在stash狀態與原版本之間的不同變化。當沒有<stash>給定時,顯示最新stash的變化。預設情況下,命令顯示diffstat,它可以接受任何已知的git diff格式(例如,git stash show -p [email protected]{1}是檢視第二最近stash的變化)。你可以使用stash.showstat和/或stash.showpatch配置變數來改變預設的行為。也就是使用git stash show -p [email protected]{1}來檢視stash的內容變化。