0

I created a project using Visual studio and pushed the git changes to Bitbucket.

Now, I thought of moving the .git folder to another drive where I can create a separate global location for all local gits in the future. When Syncing with the cloud, it showed me that all my files were deleted (understandable as the code files are not with the .git folder anymore).

The question is how can I link the git from its new dir to the solution dir? So it can sees that nothing was deleted and all files are still there.

Thank you

  • Why would you want the .git/ folder in a different location than the project? Was that the intention? – Tom Aug 14 '20 at 13:42
  • That's not really recommended to have the '.git' directory elsewhere. But if you **really** want, you could try to set `GIT_DIR` env var for VisualStudio. See https://stackoverflow.com/a/60213402/717372 – Philippe Aug 14 '20 at 14:03
  • Doing a symlink/junction instead of moving the folder seems a much better idea... – Philippe Aug 14 '20 at 14:06
  • @Tom The idea is that i don't have to recreate a local git whenever i make a sandbox of a project for development, but rather create a copy of the latest project folder and link it to the (only) local git that i created previously. ( im pretty new to git so i understand if my idea is wrong) – ShortCircuit Aug 14 '20 at 14:06
  • @ShortCircuit do you mean by "recreate a local git whenever i make a sandbox of a project for development" something like switching branches? as @Philippe has pointed out, it's not recommended that you separate the working copy from the .git/ folder. If you want to have multiple local working copies with Git you might want to look into `git worktree` and this answer https://stackoverflow.com/questions/6270193/multiple-working-directories-with-git. – Tom Aug 15 '20 at 08:00

0 Answers0