执行git stash不会删除git local中的更改

时间:2015-07-10 06:46:33

标签: git git-stash

当我git status时,我看到一些文件有本地更改(似乎是缩进更改)。

当我执行git stash时,它不会从队列中删除这些文件。它阻止我的自动拉取脚本从远程git获取。

$ git stash
Saved working directory and index state WIP on develop: 05c60a5 Merge remote-tracking branch 'origin/develop' into develop
HEAD is now at 05c60a5 Merge remote-tracking branch 'origin/develop' into develop

$ git stash
On branch develop 
Your branch and 'origin/develop' have diverged and have 23 and 127 different commit(s) each, respectively.

Changed but not updated:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) 

    modified:   config/buznames/businessname_map.
    modified:   public/css/_lib/dropdown.less
    modified:   public/css/_lib/secureBadge.less

1 个答案:

答案 0 :(得分:1)

git stash将删除所有未提交的更改,但不会删除您的本地(未提交)提交。

我相信你的本地分支已经分歧,当你试图拉动时你就会遇到合并冲突。在继续执行拉取请求之前,您必须解决这些冲突。

如果您尝试删除开发分支中与远程分支相关的所有本地提交,您可以执行以下操作:

$ git checkout develop
$ git fetch origin develop
# Reset develop branch back to origin/develop
$ git reset --hard origin/develop

注意:这将删除/取消您所有的本地委托。你将无法恢复他们