I am trying to create a git repository located within a OneDrive synced folder, but I am running into an issue.
I use OneDrive to sync folders between my multiple device
The OneDrive sync client now supports syncing folders that contain the period character within them '.' this should enable you to start syncing those git repositories automatically so long as they are within your OneDrive folder.
Get the latest version of the OneDrive Client and you are all set.
Manual creating folder with name ".git" works, and ".git" appears on the onedrive server.
OneDrive does not (yet!) support syncing files that start with periods, like the .git folder where the git metadata is saved to.
Because of this you are not seeing those items sync over OneDrive.
(This is only the case with old version of the OneDrive Client, I've created a new answer that reflects the current versions capabilities 8/2015)
Manually syncing from office.com and patiently merging any conflicts worked for me so far. Next test will be to see how it performs day-day. I know that oneDrive is not an ideal solution, but for privacy sometimes it is an easy way to get GitHub-like functionality for passing files back and forth between workspaces.
I'm not answering the question as I believe there is not a straight forward answer. But the use case is compelling. Let's assume I like to keep all the projects I'm working on in a projects folder within the OneDrive synced folder with all the Office magic as added value. Lets assume it is a web project. I'd have
OneDrive/Projects/
Project A/
Project B/
Documentation/
UserManuals/
Backups/
2020-09-16/
SQL-queries/
htdocs
.git
.gitignore
assets/css
index.php
Research/
Of the folders in Projekt B I'd like to sync all but htdocs (and perhaps the Backup) folder as it already is under some sort of version control (git) with a Git server (BitBucket). For me this is a very common thing and I have yet to come up with a satisfying solution. Of course I could move out the htdocs folder (and Backup) to somewhere outside the OneDrive tree, but that would make the layout brittle and finalizing and archiving the project would not be straight forward. One solution I could think of would be to move Projects outside OneDrive, add the stuff to be synced in a separate folder and add this folder as a symlink inside the OneDrive folder struct.
As of 6/27/2017, Version 2016 (Build 17.3.6917.0607)
OneDrive for business will support synching dotfiles (and dotdirectories) However, OneDrive is a VERY bad solution unless you add commit hooks to exclude files: https://support.microsoft.com/en-us/help/3125202/restrictions-and-limitations-when-you-sync-files-and-folders
Also, I dont know about how things would behave under race conditions. If there is more than one committer (inc automated stuff), it might not be safe.