0

I cannot cd into some of my .git directories on Windows.

Some of my repositories are fine. The .git directory appears as you would expect in them:
drwxrwx---+ 1 grandps Domain Users 0 Oct 11 15:42 .git I can cd into the .git directory, and ls it to see its contents.

In other repos, the .git directory shows up as a regular file. I can't cd into it or ls to see its contents. If I try to open it in Windows Explorer, I can't - Windows thinks it's a file, too.
-rwxrwx---+ 1 grandps Domain Users 68 Jun 22 12:22 .git

The repo still works as a git repository. I can run git commands just fine. I just can't get into the .git folder.

I have tried both Git Bash (MinGW64) and Cygwin. Both give the same results.

Any ideas how this could have happened, and how I can fix it?

1
  • Is the repository in question a sub module? Commented Oct 18, 2017 at 22:35

1 Answer 1

5

According to documentation, the file should contain path to the actual repository directory.

Also you can have a plain text file .git at the root of your working tree, containing gitdir: to point at the real directory that has the repository. This mechanism is often used for a working tree of a submodule checkout, to allow you in the containing superproject to git checkout a branch that does not have the submodule

source: https://git-scm.com/docs/gitrepository-layout

Sign up to request clarification or add additional context in comments.

1 Comment

That was it, thanks! The repos with this issue were all extra worktrees in a repo that had multiple branches checked out into different working directories. I was able to cat the .git file to see the path of the .git directory in the original worktree.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.