Skip to content

Cannot lock the ref -> detached HEAD #186

Closed
@lchiocca

Description

@lchiocca

When rebasing a sym-linked repository, I'm getting a detached head in 2.4.2.1, which didn't happen in 2.4.0.1. The setup is as following:

  • Referencing git.exe through the path, but the same error occurs with git-cmd.exe and git-bash.exe
  • clone a repo
  • create a "git-new-workdir" repo. The script can be found in the official git repo under "contrib/workdir/git-new-workdir". But I guess you know this. I have converted this to a batch file in case you need it
  • git rebase the symlinked repo -> issue

Here is the console output (first with 2.4.0.1 then with 2.4.2.1):

c:\workspace\git\MyCompany\5.90\CompanyProduct>mklink /d c:\git c:\PortableGit-2.4.0.1
symbolic link created for c:\git <<===>> c:\PortableGit-2.4.0.1

c:\workspace\git\MyCompany\5.90\CompanyProduct>git status
On branch 5.90
Your branch is up-to-date with 'origin/5.90'.
nothing to commit, working directory clean

c:\workspace\git\MyCompany\5.90\CompanyProduct>git rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded 5.90 to refs/remotes/origin/5.90.

c:\workspace\git\MyCompany\5.90\CompanyProduct>git status
On branch 5.90
Your branch is up-to-date with 'origin/5.90'.
nothing to commit, working directory clean

c:\workspace\git\MyCompany\5.90\CompanyProduct>rd c:\git

c:\workspace\git\MyCompany\5.90\CompanyProduct>mklink /d c:\git c:\PortableGit-2.4.2.1
symbolic link created for c:\git <<===>> c:\PortableGit-2.4.2.1

c:\workspace\git\MyCompany\5.90\CompanyProduct>git status
On branch 5.90
Your branch is up-to-date with 'origin/5.90'.
nothing to commit, working directory clean

c:\workspace\git\MyCompany\5.90\CompanyProduct>git rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded 5.90 to refs/remotes/origin/5.90.
error: unable to create directory for .git/refs/heads/5.90
fatal: update_ref failed for ref 'refs/heads/5.90': Cannot lock the ref 'refs/heads/5.90'.
Could not move back to refs/heads/5.90

c:\workspace\git\MyCompany\5.90\CompanyProduct>git status
HEAD detached at refs/heads/5.90
nothing to commit, working directory clean

c:\workspace\git\MyCompany\5.90\CompanyProduct>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions