Search code examples
gitgithubgit-mergegit-rebasegit-shell

Interactive rebase to squash commits is hanging


git rebase -i $(HASH) is hanging .. never completes.

Here's command the

git rebase -i d8c0f59d5d627efb65b47264d5169e3626195839

Doing this to squash some of the commits.. Since it is interactive - it asks open an editor twice as expected.

Then prints something like

 [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(-)

And then.. nothing happens - git rebase waits/hangs indefinitely.

I am using git-shell from GitHub on Windows, latest version.

Tried to trace git rebase as following:

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

It shows latest output before it starts hanging:

 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'

So the latest command that was executed by git rebase was git notes copy --for-rewrite=rebase and it succeeded, according to the trace (run time 0.0069s).
Nothing happens afterwards.

I am an old-school SVN and learning git, but this appears to me a bug of GitHub's portable version of git?

PS: I was trying to do strace to, but mingw's strace under Windows doesn't look very useful.


Solution

  • Instead of using the portable Git embedded in GitHub Desktop, try again with:

    • the latest Git for Windows you can find, like PortableGit-2.12.1-64-bit.7z.exe (unzip it anywhere you want, no setup)
    • then in a CMD session, set your PATH with:

      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\
      
    • set your HOME in that same CMD session

      set HOME=%USERPROFILE%
      
    • Finally, still from that same CMD (with its simplified PATH), cd to your Git local repo, and try your rebase again.
      Do a git rebase --quit first before re-attempting the rebase.