
Create a public/private ssh key to access the git repo with (more correctly, to access the user account that has the git repos), and add the public key to the /home/username/.ssh/authorized_keys file. control is to the user directory, not to the repos in the directory). You can put more than one git repo in the user directory, but all the repos will have common access (i.e. “git”), the git repos will be stored in the “git” user home directory. I use FreeBSD for my server OS, but this procedure applies equally to Linux. Here is my setup, note that it requires having ssh login capability to the server. This is the only way to preserve repo integrity! The upstream repo will be locked and the push will be done in an atomic action.
#Ssh git add remote repository update
Only a git push command should be used to update an upstream server. Uggg! This is NOT what you want to have happen. The worst outcome is that the loser will lose their commit entirely (their local repo will be overwritten by the copy on the server from the winning user), or the server repo will be corrupted with some files from the first user and some from the second user. The best outcome is that Nextcloud will notify the loser of a sync collision (a file was modified locally at the same time it was modified on the server), and that the collision will need to be corrected manually. These and similar services should NEVER be used to synchronize git repo’s because they don’t synchronize everyone simultaneously.įor example, if I push to a local repo in my ~/Nextcloud directory, another developer could be pushing to their local repo at about the same time, and there will be a race between our Nextcloud clients to see whose updates make it to the Nextcloud server first.


First, NEVER use a file synchronization service such as Nextcloud or Dropbox to synchronize git repos among multiple users.
