How to relocate Arduino and ArduinoData folders from Documents to inside GitHub?

For Arduino Ide on a Windows 10 laptop, I want to relocate Arduino and ArduinoData folders from the Documents folder to a folder inside of a GitHub Project so I can do version control and share development with another remote person via GitHub.

The IDE install creates those folders, so IDE obviously knows where they are.

Where does it store that knowledge?

Is it a Registry value?
Is it hardcoded?

Wherever it is, can it be changed?


Where does it store that knowledge?

C:\Users{user name}\Documents\Arduino is the default sketchbook folder location. The sketchbook folder location is stored in a file named preferences.txt under the sketchbook.path property. You can find the location of preferences.txt at the line following File > Preferences > More preferences can be edited directly in the file.

As for C:\Users{username}\Documents\ArduinoData, that is likely determined by querying Windows, either something like %USERPROFILE%/Documents or the Windows registry.

can it be changed?

You can change the sketchbook folder location in the Arduino IDE at File > Preferences > Sketchbook location. Or edit preferences.txt if you prefer, but be sure to close all Arduino IDE windows first.

When using the Microsoft Store app version of the Arduino IDE, I don't think there is any way to change the data folder location. However, if you use the "Windows Installer, for Windows XP and up" or the "Windows ZIP file for non admin install" links on the Downloads page, and install the Arduino IDE outside the C:\Program Files (x86) or C:\Program Files folders (because Windows 10 puts more strict security restrictions on those folders), you can run the Arduino IDE in portable mode:

That will cause the portable subfolder of the Arduino IDE installation folder to be used as the data folder. You are still stuck with that specific location, but you can install the Arduino IDE anywhere you like, so this gives you some flexibility over where that folder is located.

so I can do version control and share development with another remote person via GitHub.

Version control really isn't meant to be done with binary files like you fill find in the ArduinoData folder, and especially not with the large binaries you find there. Your repository will get huge very quickly, which will make it very annoying to work with. GitHub doesn't guarantee they will allow repositories to exceed 1 GB.

There really isn't anything in ArduinoData that needs to be version controlled. Maybe preferences.txt, but it's probably much less effort to just redo your preferences if there is a problem than version controlling that file.

Just document which versions of the boards packages you are using, and how to install them, and forget about ArduinoData.

Even when it comes to the sketchbook folder, I wouldn't recommend version controlling the whole folder as a single repository. That would make for a very messy and confusing commit history. GitHub allows you to have as many free repositories as you like, so make one repository for each custom sketch and custom library.