I've used GitHub to store my Git repositories since many years, wasn't very super joyful about the morons from Microsoft taking control over it, and feel even less motivated to keep using it now they're looting the open source community's work. Given that all I need is a storage shared between my devices to be able to work easily on any of them and have a backup of my work, I decided to look for info about how to setup my own git server on my NAS. Some NAS seem to offer that kind of service ready to use, but my Buffalo LS510D doesn't seem to. This is the memo of how I did instead.
First I've edited /etc/fstab to automatically mount a shared folder from my NAS to a local folder, and added the line //NAS_IP/SHARED_FOLDER /mnt/NAS cifs username=****,password=****,vers=1.0,auto,x-systemd.automount,,iocharset=utf8,sec=ntlm 0 0. To be done on each device needing to access the repositories.
Replace **** with your username and password (the one used to connect to the NAS), NAS_IP with the IP address of the NAS (if you don't know it, arp should help you to find it), SHARED_FOLDER with the name of the shared folder (must have been setup through your NAS admin interface, try access it by navigating to its IP in a web browser), and /mnt/NAS with the path to the folder on your device where the NAS shared folder will be mounted (make sure to create it if it doesn't exist). Reboot to actually mount the shared folder, or use sudo mount /mnt/NAS to do it manually.
Create a folder on your shared NAS folder to store the repositories, I'll call it /mnt/NAS/GitRepos. Create a "Dummy" repository to test everything's working: cd /mnt/NAS/GitRepos && mkdir Dummy && cd Dummy && git init --bare. Now come back to your local device, clone the repository and add a file to it: cd ~ && git clone /mnt/NAS/GitRepos/Dummy && cd Dummy && echo "hello world" > README && git add README && git commit -m "The first commit!". Push your modifications to the origin on the NAS: git push. Create a branch, add a new file to it and push it: git checkout -b test && echo "Test" > test.txt && git add test.txt && git commit -m "Test a branch" && git push --set-upstream origin test (--set-upstream only needed the first time you push a new branch).
Everything is working fine, you can now work as you would if you where using GitHub, pushing/pulling your work between devices, working locally on each (no need to be permanently connected), and having a backup of your repos on a seperate device, 100% private. Downside, if you need to make a repository public you need to prepare yourself a zip of the repo and host it on a webpage; and you can't access origin if you're away from your home local network (some NAS also have a web access functionality which could help).