OneDrive 同步文件夹中的 Git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25735148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:26:26  来源:igfitidea点击:

Git repository in OneDrive synced folder

gitonedrive

提问by Ryan

I am trying to create a git repository located within a OneDrive synced folder, but I am running into an issue.

我正在尝试在 OneDrive 同步文件夹中创建一个 git 存储库,但我遇到了一个问题。

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.

我使用 OneDrive 通过“云”在我的多个设备之间同步文件夹。在我的开发机器(Win 7 64)上,OneDrive 文件夹位于 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.

我在该目录中创建了一个 \git 子文件夹,并在该文件夹中为我的代码 (foo.git) 创建了一个 git 存储库。

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

在同一台机器上,我可以将该存储库克隆到另一个未与 OneDrive 同步的文件夹,并推送和拉取更改。

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.

然而,在我的另一台机器(Win 8.1 64)上,它也与 OneDrive 同步,当我尝试克隆存储库时(看起来一切都在 C:\Users\myusername\OneDrive\git\foo.git 下),我收到“这不是有效的 git 存储库”错误。

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).

两台机器之间的 \git 文件夹内容“应该”相同,因为它们是同步的。我唯一能想到的是我的 git 存储库中可能有一些未同步的隐藏文件夹/文件。OneDrive 应该同步所有内容,包括隐藏文件和文件夹(据我所知)。

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

远程 git 存储库中是否有隐藏的文件夹或文件?

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?

我不确定为什么这不起作用,我读过其他人使用 OneDrive 存储 git 远程存储库没有问题。也许一台机器是Win 7而另一台机器是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?

当我用尽我的谷歌搜索试图找到解决方案时,有没有人对我可能做错的事情有任何建议或见解?

采纳答案by Peter Nied

OneDrive does not (yet!) support syncing files that start with periods, like the .git folder where the git metadata is saved to.

OneDrive 不(还!)支持同步以句点开头的文件,例如保存 git 元数据的 .git 文件夹。

Because of this you are not seeing those items sync over OneDrive.

因此,您看不到这些项目通过 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)

(这仅适用于旧版 OneDrive 客户端,我创建了一个反映当前版本功能 8/2015 的新答案)

回答by Peter Nied

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.

OneDrive 同步客户端现在支持同步包含句点字符“.”的文件夹。这应该使您能够开始自动同步这些 git 存储库,只要它们在您的 OneDrive 文件夹中。

Get the latest version of the OneDrive Clientand you are all set.

获取最新版本的OneDrive 客户端,一切就绪

回答by Alan Berezin

As of 6/27/2017, Version 2016 (Build 17.3.6917.0607)

截至 2017 年 6 月 27 日,版本 2016(内部版本 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

OneDrive for business 将支持同步点文件(和点目录)但是,除非您添加提交挂钩以排除文件,否则 OneDrive 是一个非常糟糕的解决方案:https: //support.microsoft.com/en-us/help/3125202/restrictions-and-同步文件和文件夹时的限制

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.

另外,我不知道在竞争条件下事情会如何表现。如果有多个提交者(包括自动化的东西),它可能不安全。

回答by cluelessgumshoe

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.

到目前为止,从 office.com 手动同步并耐心地合并任何冲突对我有用。下一个测试将是查看它的日常表现。我知道 oneDrive 不是一个理想的解决方案,但为了隐私,有时它是一种获得类似 GitHub 功能的简单方法,用于在工作区之间来回传递文件​​。

回答by dvda

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

手动创建名称为“.git”的文件夹有效,“.git”出现在 onedrive 服务器上。

回答by lboshuizen

I had the same using DropBox and also OneDrive.

我使用 DropBox 和 OneDrive 也是如此。

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

文件夹完全同步并且其他客户端完全知道更改需要一些时间。如果缺少某些东西,git 会像预期的那样抱怨。

Manually forcinga sync on bothsides 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 ;-))

我怀疑它在(或由)Windows 上实现的方式导致了它。Ubuntu 上的 Dropbox 没有显示问题。(除非我很着急,并希望 3 秒后我的另一个盒子完全同步;-))

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

我放弃了 DB & OD 解决方案。最后我决定在github上注册一个账号。方便多了。

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

在一个盒子上安装 GitLab 或 Gitblit(在 Win 上使用 Tomcat)之类的东西对私有存储库也有帮助。