# Windows – .gitignore for OneDrive

onedriveregexwindows 10

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.

• 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:

1. OneDrive version 20.201 and higher
2. Windows Pro/Education or any Windows that has a Group Policy Editor
4. This must also be the OneDrive Client. You can still upload the blocked file types via the web interface(!)

Steps:

1. Go to %localappdata%Microsoft/OneDrive/<VersionNumber>/adm
2. In there, copy the OneDrive.adml and OneDrive.admx files.
3. Navigate to C:/Windows/PolicyDefintions and paste the files here. It is possible that you need to also paste them into the region-specific folders: I had to paste them into en-US, which is not my region.
4. Open the Group Policy Editor: Hit the Windows key and type GPO, Enter
5. 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.
6. Head over to the highlighted line, "Exclude specific kinds of files from being uploaded", right-click it and select Edit.
7. The Edit Window looks like this:
8. Tick the Enable radio button and then click on Show.
9. A new window opens. In there, you can add every file ending (plus the period symbol: i.e. write .exe, not exe. Here is how it looks for me having added a file ending:
10. 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:

1. Only the .admx file was copied, but .adml was missing -> both need to be copied
2. The .admx/.adml files were in the general Policy Folder, but not the region-folder such as en-US or en-GB. This can lead to an error when starting the Group Policy Editor saying that the file specified cannot be found.
3. 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.