0

As explained here Can I store the .git folder outside the files I want tracked?

you can use the command git init --separate-git-dir to move your .git folder elsewhere on the local drive.

A file called .git is created in your working directory to point to the .git folder.

So, the question: can I change the default name of that file, making it something like .git.win for example?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Jabot
  • 5
  • 2
  • Could you give some context: why do you want or need that file to be called something different? – jonrsharpe Jul 03 '18 at 08:55
  • Why would you want to do that? – Maroun Jul 03 '18 at 08:55
  • Why do you want to do that? I suspect you are trying to solve a different problem. – axiac Jul 03 '18 at 09:04
  • The reason behind my question was that my repo is backed up by Dropbox. That’s why I need to keep the .git folder elsewhere on the local machine. Since my machines run Linux and Windows, I thought the path in the `.git` file should change depending on which OS is running. But it shouldn't: you can put relative paths there with compatible syntax. My `.git` file now looks like this: `gitdir: ../../folder/gitfolder`. This works on both Linux and Windows. – Jabot Jul 03 '18 at 20:32

1 Answers1

2

The answer is No.

Git is looking for the specific file named .git which points to the original repo path.

A similar thing happening when you use git worktree. The worktree will have a .git file which points to the original repo path + worktree.

You must have a .git in your git repository.

enter image description here

And the same mechanism is used in git worktree

enter image description here

CodeWizard
  • 128,036
  • 21
  • 144
  • 167