【问题标题】:Interactive rebase to squash commits is hanging用于压缩提交的交互式 rebase 挂起
【发布时间】:2017-08-19 14:51:16
【问题描述】:

git rebase -i $(HASH) 挂起......永远不会完成。

这里是命令

git rebase -i d8c0f59d5d627efb65b47264d5169e3626195839

这样做是为了压缩一些提交。由于它是交互式的 - 它要求打开编辑器两次。

然后打印类似

 [detached HEAD fc62e0b3] AIRFLOW-1012 -
 add run_as_script parameter  
 Author: Tagar  
 Date: Sun Mar 19 12:50:50 2017 -0600
 2 files changed, 14 insertions(+), 3 deletions(-)

然后.. 什么也没有发生 - git rebase 无限期地等待/挂起。

我在 Windows 上使用来自 GitHub 的 git-shell,最新版本。

尝试追踪git rebase如下:

set -x; GIT_TRACE=2 GIT_CURL_VERBOSE=2 GIT_TRACE_PERFORMANCE=2 \
GIT_TRACE_PACK_ACCESS=2 GIT_TRACE_PACKET=2 GIT_TRACE_PACKFILE=2 \
GIT_TRACE_SETUP=2 GIT_TRACE_SHALLOW=2 \
git rebase -i d8c0f59d5d627efb65b47264d5169e3626195839

它在开始挂起之前显示最新的输出:

 20:03:58.266245 trace.c:435             performance: 13.236119523 s:
 git command:
 'C:\Users\myuser1\AppData\Local\GitHubPortableGit_f02737a78695063deace08e96d5042710d3e32db\mingw32\libexec\git-core\git.exe'
 'commit' '-n' '--amend' '-F' '.git/SQUASH_MSG' '-e' 20:03:58.293248
 run-command.c:350       trace: run_command: 'notes' 'copy'
 '--for-rewrite=rebase' 
 20:03:58.371255 trace.c:333             setup:
 git_dir: .git 
 20:03:58.372255 trace.c:334             setup:
 git_common_dir: .git 
 20:03:58.372255 trace.c:335             setup:
 worktree: C:/Users/myuser1/Documents/GitHub/incubator-airflow
 20:03:58.372255 trace.c:336             setup: cwd:
 C:/Users/myuser1/Documents/GitHub/incubator-airflow
 20:03:58.372255 trace.c:337             setup: prefix: (null)
 20:03:58.372255 git.c:371               trace: built-in: git 'notes'
 'copy' '--for-rewrite=rebase' 
 20:03:58.372255 trace.c:435            
 performance: 0.006984451 s: git command:
 'C:\Users\myuser1\AppData\Local\GitHub\PortableGit_f02737a78695063deace08e96d5042710d3e32db\mingw32\libexec\git-core\git.exe'
 'notes' 'copy' '--for-rewrite=rebase'

因此,git rebase 执行的最新命令是git notes copy --for-rewrite=rebase,根据跟踪(运行时间 0.0069 秒),它成功了。
之后什么也没有发生。

我是一个老派的 SVN,正在学习 git,但在我看来,这似乎是 GitHub 便携式版本 git 的一个错误?

PS:我试图做strace to,但是mingw在Windows下的strace看起来不是很有用。

【问题讨论】:

    标签: git github git-merge git-rebase git-shell


    【解决方案1】:

    不要使用嵌入在 GitHub Desktop 中的便携式 Git,而是使用以下命令重试:

    • 你可以找到latest Git for Windows,比如PortableGit-2.12.1-64-bit.7z.exe(解压到任意位置,无需设置)
    • 然后在CMD 会话中,将PATH 设置为:

      set G=c:\path\to\latest\git
      set PATH=%G%\bin;%G%\usr\bin;%G%\mingw64\bin
      set PATH=%PATH%;C:\windows\system32;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\
      
    • 在同一 CMD 会话中设置您的 HOME

      set HOME=%USERPROFILE%
      
    • 最后,仍然从同一个 CMD(使用其简化的 PATH),cd 到您的 Git 本地存储库,然后再次尝试您的 rebase。
      在重新尝试变基之前执行git rebase --quit first

    【讨论】:

    • 谢谢!它确实是以前可移植版本的 git 中的一些错误。在最新的 2.12.1 中运行 git rebase 后按预期工作。
    猜你喜欢
    • 2010-12-16
    • 1970-01-01
    • 2019-08-14
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 2017-10-27
    • 1970-01-01
    • 2020-12-04
    相关资源
    最近更新 更多