[jerry@CentOS project]$ git status -s M string.c ?? string
现在要切换分支机构为客户不断升级,但你不想提交你的工作,所以你会藏匿的变化。要推一个新的藏匿到您的堆栈,运行git stash命令[jerry@CentOS 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命令验证。[jerry@CentOS project]$ git status -s ?? string
现在可以安全地切换分支和做其他工作。我们可以看到的藏匿的变化列表通过使用 git stash list 命令。[jerry@CentOS project]$ git stash list stash@{0}: WIP on master: e86f062 Added my_strcpy function
假设你解决了客户不断升级和你要回到你的工作,已经做了一半的代码。只要执行git stash pop 命令,它会从堆栈中删除的变化,并把它放在当前工作目录。[jerry@CentOS project]$ git status -s ?? string
[jerry@CentOS 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/stash@{0} (36f79dfedae4ac20e2e8558830154bd6315e72d4) [jerry@CentOS project]$ git status -s M string.c ?? string