简体   繁体   English

如何阻止 OneDrive 在 Windows 上下载 git.exe?

[英]How do I stop OneDrive from downloading git.exe on Windows?

I have used Git on Windows for a while, but recently changed the setting and got this.我在 Windows 上使用 Git 有一段时间了,但最近更改了设置并得到了这个。

On almost every command for Git Bash (also on PowerShell and Github Desktop) I get在几乎每个 Git Bash 命令(也在 PowerShell 和 Github Desktop 上)我得到

git.exe is being downloaded on OneDrive

(translation may not be exactly the same) (翻译可能不完全一样)

The setting that changed recently is moving my repos to a OneDrive folder in order to have them synced between two sessions: that is work desktop and remote virtual machine.最近更改的设置是将我的存储库移动到 OneDrive 文件夹,以便它们在两个会话之间同步:即工作桌面和远程虚拟机。

I can see that this may not be ideal, but it really works for me since I have the same settings on both sessions, and not really get used to doing many commit-push-pull.我可以看到这可能并不理想,但它确实对我有用,因为我在两个会话中都有相同的设置,并且不太习惯执行许多提交推拉。 Not the main topic here, but feel free to comment.不是这里的主要话题,但请随时发表评论。

(Edit): Upon reading solution, there are other ways to set this syncing that doesn't mess up with the internals of Git. (编辑):在阅读解决方案时,还有其他方法可以设置这种同步,不会与 Git 的内部结构混乱。 Look for that instead.寻找那个。 Thanks.谢谢。

In any case, the strange thing is that the notifications happen only on the Remote Virtual Machine, but not on the desktop.无论如何,奇怪的是通知只发生在远程虚拟机上,而不发生在桌面上。

I have seen some notifications about some files in the repos, which I then attribute to OneDrive being nosy about every move I make file I move.我在存储库中看到了一些关于某些文件的通知,然后我将这些通知归因于 OneDrive 对我移动文件的每一个动作都很八卦。 But then I've also seen files I don't know about, and theres always git.exe attached to the notification.但是后来我也看到了我不知道的文件,并且通知中总是git.exe

In the first scenario I have tried tuning down the notifications for OneDrive.在第一个场景中,我尝试调低 OneDrive 的通知。 Some might say Microsoft does have a background for not letting users setup their notifications, so I'm still looking.有人可能会说微软确实有不让用户设置他们的通知的背景,所以我还在寻找。

Thanks.谢谢。

Most file syncing tools like OneDrive and Dropbox operate by syncing data file by file.大多数文件同步工具(如 OneDrive 和 Dropbox)通过逐个文件同步数据来运行。 This is a great approach if you're working on a single word-processing document or spreadsheet.如果您正在处理单个文字处理文档或电子表格,这是一种很好的方法。 However, it's not as great when you're working with a Git repository.但是,当您使用 Git 存储库时,它就没有那么好了。

When changing between branches or making a commit, Git changes and creates a lot of files all at once.在分支之间更改或进行提交时,Git 会同时更改并创建大量文件。 In order to be synced correctly, all of the created files must be written in a similar order: all the blobs must be written, then the trees, then the commits, and then the refs can be updated.为了正确同步,所有创建的文件必须以类似的顺序写入:必须写入所有 blob,然后是树,然后是提交,然后可以更新引用。 If you do this out of order, your repository can be corrupted, since you can have branches that refer to objects that don't exist (or objects that refer to other objects that don't exist).如果您不按顺序执行此操作,则您的存储库可能会损坏,因为您的分支可能会引用不存在的对象(或引用不存在的其他对象的对象)。

In addition, these tools can end up deleting files you wanted to have in your working tree or recreating files you didn't.此外,这些工具最终可能会删除您希望在工作树中拥有的文件或重新创建您没有的文件。 So overall, you don't want to sync any Git repository using one of these tools.所以总的来说,您不希望使用这些工具之一同步任何 Git 存储库。

You can write a bundle file with git bundle and sync that, or you can use rsync to sync a repository provided it's idle (not being modified) when you do.您可以使用git bundle编写一个包文件并同步它,或者您可以使用rsync来同步存储库,前提是它在您这样做时处于空闲状态(未被修改)。 Note that if you sync a working tree, Git will need to refresh all files when you sync it across to the new machine, and also Git doesn't try to defend against untrusted users who have access to the working tree.请注意,如果您同步工作树,当您将其同步到新机器时,Git 将需要刷新所有文件,而且 Git 不会尝试防御有权访问工作树的不受信任的用户。

It's also not a good idea to sync your Git installation itself via OneDrive, which is what it sounds like might be happening.通过 OneDrive 同步您的 Git 安装本身也不是一个好主意,这听起来可能正在发生。 Instead, install Git for Windows on each machine independently and don't try to sync it across.相反,在每台机器上独立安装适用于 Windows 的 Git,不要尝试同步它。 OneDrive should have configuration options that let you control what's synced. OneDrive 应具有可让您控制同步内容的配置选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM