git - 中止 rebase 后如何应用自动存储?

标签 git rebase git-rebase git-stash

我在 .gitconfig 中将 rebase.autoStash 设置为 'true',这样我就可以运行 rebase 在脏工作树上。但是,如果 rebase 由于某种原因中止,则对跟踪文件的所有更改都将消失(即不会重新应用自动存储)。在这种情况下应用自动存储的正确方法是什么?

如何重现:

  • 运行 git config rebase.autostash true
  • 编辑一些跟踪文件。
  • 运行 git rebase -i HEAD^^^。这会打印如下内容:

    Created autostash: 75a5188
    HEAD is now at f0c93f1 WIP
    
  • 中止 rebase ,例如让编辑器退出并显示错误代码(Vim 中的 :cq)。

最佳答案

您可以使用 git stash applygit rebase 打印的 SHA-1 哈希来应用 autostash:

$ git rebase -i HEAD^^^
Created autostash: 3ac3f4a
HEAD is now at f0c93f1 WIP
# abort the rebase...    
$ git stash apply 3ac3f4a
On branch master
...

关于git - 中止 rebase 后如何应用自动存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37252108/

相关文章:

Git 在交互式 rebase 中预先添加所有提交消息

git - 需要 git rebase -Ignore-all-space 来保留我的空间

git - 向 Gitlab 添加了 SSH key ,但它仍然要求我提供凭据

git:重写历史:重新排序和 merge 提交

git - 在shell脚本中获取git返回值

git - cherry-picked feature commits to new branch, reverted commits, rebase 不按预期工作

git - 如何编辑 github 存储库中的初始提交?

git - Azure DevOps GIT(gitflow)如何在开发分支上强制执行 pull 请求并保持原点最新?

git - 要下载哪个 msysgit 版本?

git - 使用 JGit 中止 merge