Life's random bits By b1thunt3r (aka Ishan Jain)…
Working with Git Repository in OneDrive

Working with Git Repository in OneDrive

Ishan jain
Work with both Git and OneDrive (or any other cloud storage) simultaneously.

There have been some rare occasions when I like to work with git repository in OneDrive. It may not be best practice, but it get work done!

After spending some time searching on Internet, i stumbled on this solution.

Instead of having .git folder in the root of teh repository, git allows you to have magic .git file.

In the .git file, add this:

gitdir: /path/to/.git

Example

  1. Check out the git repository somewhere on your local machine

  2. Create a new project folder on OneDrive

  3. Move content from (except or .git folder) to project folder on OneDrive

  4. Create a new .git file in root of project folder on OneDrive

  5. Add path to .git folder in the .git file in root of project folder on OneDrive

    gitdir: /path/to/.git
    

Now you can run git from your project folder on OneDrive without syncing git data.

Windows

You can use double backslash on Windows:

gitdir: P:\\path\\to\\.git