git stash儲存恢複進度

來源:互聯網
上載者:User

如果改動了working area和staging area的檔案,需要儲存起來,然後忽略這些改動,回到最後一次提交的狀態。可以使用git stash.

假定項目中有一個檔案t,先用git rm t 從刪除之,這時候working area中該檔案消失了。

然後執行git stash命令,再看working area中,該檔案又回來了。

這時候調用git stash list命令,看到:

git stash liststash@{0}: WIP on master: 1c47165 change package name

這次的改動沒有徹底丟掉,而是被儲存到stash list中。可以認為是擱置爭議,保留個人意見,雖然服從了大局,但是個人的意見還是存在了一個stash list的地方,以後隨時可以拿出來。

拿出來的話,用git stash pop,

Removing t# On branch master# Changes not staged for commit:#   (use "git add/rm <file>..." to update what will be committed)#   (use "git checkout -- <file>..." to discard changes in working directory)##deleted:    t## Untracked files:#   (use "git add <file>..." to include in what will be committed)##deploy.tar.bz2no changes added to commit (use "git add" and/or "git commit -a")Dropped refs/stash@{0} (8e32484d1da7ab8e47986e1aff39a5711087dcc2)

結果可以看到,又回到我用git rm刪除t檔案的狀態。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.