Git 藏匿操作

來源:互聯網
上載者:User

標籤:pos   目錄   ted   commit   切換   key   size   tag   har   

假設您正在為您的產品實施的一項新功能。你的代碼是在推進開發進度而客戶不斷升級需求突然來了。正因為如此,你必須保持放下你的新功能,工作幾個小時。你不能提交你的部分代碼,也不能扔掉你的變化。所以,你需要一些臨時空間,在那裡你可以儲存你的部分修改,以便以後再提交。

在Git中,藏匿操作需要修改的追蹤檔案和階段的變化,並將其儲存在棧上未完成的更改,可以在任何時候重新。

[[email protected] project]$ git status -s M string.c ?? string

現在要切換分公司為客戶不斷升級,但你不想提交你的工作,所以你會藏匿的變化。要推一個新的藏匿到您的堆棧,運行git stash命令

[[email protected] project]$ git stash Saved working directory and index state WIP on master: e86f062 Added my_strcpy function HEAD is now at e86f062 Added my_strcpy function

現在你的工作目錄是乾淨的,所有的改變都儲存在堆棧。讓我們用git status命令驗證。

[[email protected] project]$ git status -s ?? string

現在可以安全地切換分支和做其他工作。我們可以看到的藏匿的變化列表通過使用 git stash list 命令。

[[email protected] project]$ git stash list [email protected]{0}: WIP on master: e86f062 Added my_strcpy function

假設你解決了客戶不斷升級和你要回到你的工作,已經做了一半的代碼。只要執行git stash pop 命令,它會從堆棧中刪除的變化,並把它放在當前工作目錄。

[[email protected] project]$ git status -s ?? string

[[email protected] project]$ git stash pop

上面的命令會產生以下結果。

# On branch master # Changed but not updated: # (use “git add …” to update what will be committed) # (use “git checkout — …” to discard changes in working directory) # # modified: string.c # # Untracked files: # (use “git add …” to include in what will be committed) # # string no changes added to commit (use “git add” and/or “git commit -a”) Dropped refs/[email protected]{0} (36f79dfedae4ac20e2e8558830154bd6315e72d4) [[email protected] project]$ git status -s M string.c ?? string

PS:如果您想和業內技術大牛交流的話,請加qq群(521249302)或者關注公眾 號(AskHarries),謝謝!

Git 藏匿操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.