Psychotechnopath
Psychotechnopath

Reputation: 2744

Dual-booting Linux & Windows, best way to respect git workflow?

I have a PC where I have both a Linux and a windows installation. I use a cloud service so I have access to my important files in both places, and they are synced.

Say I created a git repository, and pushed it to GitHub on windows. Now I suddenly feel the need to switch to my Linux installation to do some stuff. My cloud service does not sync the .git folder, since it's hidden in default by windows. (Would it lead to problems between os'es if i would sync it?). Therefore, Even though I have the same project (with exactly the same files) as on windows, Linux does not automatically recognize the VCS settings of the current project.

I found a somewhat dirty workaround, on Linux I

  1. Initialize an empty rep: git init
  2. Add a remote branch:git remote add Project_name https://github.com/Psychotechnopath/Project_name.git
  3. Fetch the contents of the remote branch git fetch --all
  4. Reset the head onto the remote master branch git reset --hard Project_name/master

Is this the best way to do it (e.g. respecting the git workflow), or are there more elegant ways?

Upvotes: 2

Views: 371

Answers (1)

Wes
Wes

Reputation: 1090

I have mostly-successfully done this on the same filesystem; in my case I mounted the ntfs filesystem from Linux. Two things you have to be careful of:

  • don't make filenames that are the same on a case-insensitive file system but different on a case-sensitive one
  • pay special attention to your line endings, you may need to do some work in .gitattributes here
  • push often in case you find a git bug

If you don't mind having the world's slowest Linux system, you can also just run Linux under Windows via Window Services for Linux, WSL. (Not WSL 2, that's containers). In that case, you can access your windows repo from linux via the /mnt/c/ filesystem.

Upvotes: 1

Related Questions