Git repository in OneDrive synced folder

我怕爱的太早我们不能终老 提交于 2021-01-20 18:58:01

问题


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 devices via "the cloud". On my development machine (Win 7 64) the OneDrive folder is located under C:\Users\myusername\OneDrive.

I created a \git subfolder in that directory and created a git repository for my code (foo.git) within that folder.

On the same machine, I can clone that repository to another folder, that is not synced with OneDrive, and push and pull changes.

However on my other machine (Win 8.1 64), which syncs with OneDrive as well, when I try to clone the repository (looks like everything is in there under C:\Users\myusername\OneDrive\git\foo.git), I get a "this is not a valid git repository" error.

The \git folder contents "should" be identical between the two machines, as they get synced. Only thing I can think of is that there may be some hidden folders/files in my git repository that are not getting synced. OneDrive is supposed to be to syncing everything, including hidden files and folders (as far as I know).

Are there hidden folders or files in a remote git repository?

I am not sure why this isn't working, I have read of others that use OneDrive to store a git remote repository without a problem. Maybe its some issue with one machine being Win 7 and the other being Win 8.1?

As I have exhausted my googlingfu trying to find a resolution, does anyone have any advice or insight as to what I might be doing wrong?


回答1:


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)




回答2:


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.




回答3:


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.




回答4:


Manual creating folder with name ".git" works, and ".git" appears on the onedrive server.




回答5:


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.




回答6:


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.




回答7:


I had the same using DropBox and also OneDrive.

It takes some time before folders are completely synced and the other clients are completely aware of the changes. If something is missing git complains as it is expected to do.

Manually forcing a sync on both sides solves it.

I suspect that the way it's implemented on (or used by) Windows causes it. Dropbox on Ubuntu didn't show the issues. (Unless I was to much in a hurry and expected a full sync on my other box 3 secs later ;-))

I gave up on the DB & OD solution. In the end I decided to take an account on github. Much more convenient.

Installing something like GitLab or Gitblit (using Tomcat on Win) on a box will help too for private repos.



来源:https://stackoverflow.com/questions/25735148/git-repository-in-onedrive-synced-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!