Git stash pop 在 master 分支上

Roh*_*hit 5 git github git-stash

我有两个分支 master 和development。我藏在主人身上,例如

git stash
git checkout development
Run Code Online (Sandbox Code Playgroud)

现在,我在开发分支,但错误地打开了存储库

git stash pop
Run Code Online (Sandbox Code Playgroud)

现在它显示出冲突。我用这个重置了 git:

git reset HEAD
Run Code Online (Sandbox Code Playgroud)

但它仍然显示出冲突。我也需要将我的藏品放回主分支。我该如何解决这个问题?

PSk*_*cik 2

git reset HEAD不会触及工作树,只会触及索引。实际上,它只会取消暂存暂存文件,因为HEAD无论如何,这是您当前分支已经所在的位置(这是 HEAD 的定义)。

git reset --hard HEAD将修复工作树以反映HEAD.

如果agit pop不能干净地应用,则应该保留该藏匿处。

来自 man git-stash:

应用状态可能会因冲突而失败;在这种情况下,它不会从存储列表中删除。您需要手动解决冲突,然后手动调用 git stash drop 。

所以就这样做:

git checkout master
git stash pop 
#or `git stash apply` if you don't want to drop the stash even if it does apply cleanly
Run Code Online (Sandbox Code Playgroud)