Git stash pop 在 master 分支上

标签 git github git-stash

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

git stash
git checkout development

现在,我在开发分支上,但错误地 pop 了存储

git stash pop

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

git reset HEAD

但是还是显示冲突。我还需要将我的藏品放回 master 分支。我该如何解决这个问题?

最佳答案

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

git reset --hard HEAD 将修复工作树以反射(reflect) HEAD

如果 git pop 没有干净地应用,应该保留存储。

来自 man git-stash:

Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards.

就这样吧:

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

关于Git stash pop 在 master 分支上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30847089/

相关文章:

git - 如何使用命令行工具 DEFLATE 来提取 git 对象?

html - Github 页面未在子文件夹上加载 css

git:将存储移动到另一个目录中的存储库

Git 专门列出一个分支的 stash

python - 从多个 git 开发分支测试 numpy python 库

git - 使用 SSH 用户名和密码将 Git 项目导入 Aptana

github - 是否可以从 git 语言统计中排除文件?

git - stash , pull 和 pop 与提交和 pull --rebase之间有重要区别吗?

GitLab 推送错误 : LFS objects are missing

git - 从别人的 Github 克隆一个 repo 并将其推送到我的 Github 上的一个 repo