"fatal: ref HEAD is not symbolic ref" during interactive git rebase

Get 3 commits - one correct, and then two stupid cleanups, typos, etc. Therefore, I want to cross them. Fire:

git rebase -i HEAD~3 

It sounds simple, and it should work - I tried it after I ran into a problem in a new repo, and it works as expected. The editor shows 3 commits, selects the top, goes through the other two, saves and exits. If I run into verbose mode, I see more detailed information - git goes into HEAD offline state, checking the 1st latch I selected, then doing "Rebasing 2/3" and "Rebasing 3/3", apparently creating some temp moves along the path - and then a message of success; the editor appears at some point, prompting me to change the commit message. Things are good.

But the same team is dying in a working repo! 3 commits in the pick-squash-squash editor .. but this time I don't see "Rebasing 2/3", instead of the very first line after HEAD is now on my SHA-1, it is deadly!

 HEAD is now at 48a6c3d... <commit message> fatal: ref HEAD is not a symbolic ref 

But why does git expect HEAD to be a symbolic ref? The reboot process really disables HEAD - just as I see in my example example - so why is it fatal in this second example, but not the first? cat.git / HEAD give me the SHA1 commit I selected ...

I spent several hours reading and researching, but something is simply not here, and I cannot find what it is! I suspect that perhaps some hooks are responsible (they know little about them and know that some have a problematic repo). Thank you for responding to this!

+6
source share
1 answer

Your β€œworking” repo will probably break somehow. See I can no longer git rebase -interactive .

I will try to run git status in your working repo to find out what is happening. Then, for example, git rebase --abort , git merge --abort or something similar may be required.

I would also run git fsck .

After your repo and working directory are good, interactive rebase should work fine. Also note that you might need git rebase --root --preserve-merges ... if you want to touch the first commit in the repo.

0
source

Source: https://habr.com/ru/post/951219/


All Articles