I've become very annoyed that my Vim temp files "can't be synced with OneDrive." I'd rather it just ignore them all together using regex or something, but I don't know how to do that.
22 Answers
Edit 17 May 2022:
Microsoft has since added this feature and has written a how-to: Link
Original answer:
As of Onedrive 20.201.xxx and later, this is possible. Granted, there are a few caveats and it is not as easy as .gitignore. I found a guide here, but it was quite brief and presumed a lot of knowledge.
First things first, here are the prerequisites:
- OneDrive version 20.201 and higher
- Windows Pro/Education or any Windows that has a Group Policy Editor
- Administrative Rights on the Windows Machine as you need access to C:/Windows
- This must also be the OneDrive Client. You can still upload the blocked file types via the web interface(!)
Steps:
- Go to
%localappdata%Microsoft/OneDrive/<VersionNumber>/adm - In there, copy the
OneDrive.admlandOneDrive.admxfiles. - Navigate to
C:/Windows/PolicyDefintionsand paste the files here. It is possible that you need to also paste them into the region-specific folders: I had to paste them intoen-US, which is not my region. - Open the Group Policy Editor: Hit the Windows key and type
GPO, Enter - Inside the Editor, navigate to
Computer Configuration > Administrative Templates > OneDrive. You should see this window:For me it is already enabled; by default it is set to
Not configured. - Head over to the highlighted line, "Exclude specific kinds of files from being uploaded", right-click it and select
Edit. - The
EditWindow looks like this: - Tick the
Enableradio button and then click onShow. - A new window opens. In there, you can add every file ending (plus the period symbol: i.e. write
.exe, notexe. Here is how it looks for me having added a file ending: - End the OneDrive process, and delete any file with that new ending. This step might be optional of you are willing to wait for OneDrive to catch up on the new rule. It will not immediately block the files with the ignored ending.
The result should look like this in your OneDrive folder:
And when I open the OneDrive Dialog via right-clicking the Taskbar icon, I see this hint:
What is really nice about this (albeit cumbersome) solution, is that I don't need any administrative rights for OneDrive itself. My company handles all of that so I don't have access to those settings.
Troubleshooting that I had come across:
- Only the
.admxfile was copied, but.adml was missing-> both need to be copied - The .admx/.adml files were in the general Policy Folder, but not the region-folder such as
en-USoren-GB. This can lead to an error when starting the Group Policy Editor saying that the file specified cannot be found. - Group Policy Editor is not available -> Must be on Windows Pro!
From the website I linked above, there is also another option that did not apply to me. From the website:
If you are using a MDM solution (like Intune) for your BYOD devices or Azure AD Joined only devices you can push the following registry:
HKLM\SOFTWARE\Policies\Microsoft\OneDrive\
Key: EnableODIgnoreListFromGPO
Type: REG_SZ Value
Name: the file type you want to exclude
Value: the file type you want to exclude
I checked my registry and I didn't have this entry.
4Not as far as I know, but it's currently "in the plans" according to Microsoft. It's tracked on OneDrive's Feedback Portal page here.
2