
Nextcloud is a powerful platform for syncing files, but did you know it can also be used to sync Git repositories? This feature allows you to keep your local Git repository in sync with the remote repository on your Nextcloud server.
To get started, you'll need to have a Nextcloud server up and running, and a Git repository set up on your local machine. Nextcloud Git sync is available in the official Nextcloud client, which can be downloaded from the Nextcloud website.
The Nextcloud Git sync feature uses the Git version control system to synchronize changes between your local repository and the remote repository on your Nextcloud server. This means you can easily collaborate with others on your projects and keep track of changes made to your code.
Related reading: Nextcloud Aio Local Only
Server Setup
You'll need to clone the basic Git repositories into the Web server's directory. Depending on your distribution, this will be either /var/www, /var/www/html, or /srv/http.
To get started, identify the user and group the Web server is running as. This will be either http, www-data, apache, or wwwrun.
The Apache user and group for the chown command will also be one of these options.
You'll need to create the data folder and adjust permissions.
For another approach, see: Nextcloud Servers
Git Sync
Git Sync is a powerful tool that allows you to mirror a GIT repo as a read-only folder in nextCloud. This is particularly useful for companies like The GMU, where sharing files with non-nextCloud users is a requirement.
The design is simple, but the implementation was more involved than expected. For example, you can't just copy files from a GIT folder to nextCloud because the file needs to be registered with the nextCloud database.
The GIT Sync tool updates nextCloud every minute with any new files or changes to the GIT repository, providing real-time syncing capabilities. This ensures that all files are up-to-date and easily accessible from nextCloud.
Here are the key requirements for GIT Sync:
- Mirror a GIT repo as read-only to a configured nextCloud user account.
- All accidental uploads to the GIT folder are to be reverted to the GIT version of the file.
- A special transfer directory, ‘Transfer’, will allow uploads.
- Files transferred to the transfer directory from say a phone are to be moved to an appropriate GIT folder in a timely fashion.
- Files transferred are purged weekly.
- Daily email report of all files processed for the day.
- Daily email of all errors processing files included in the daily email report.
- Configuration file management. Adding a repo per user can be accomplished by creating a new configuration file.
- Include and exclude directory options. The GIT repo directories can be filtered by using either an include or exclude list.
Get the Source
To get the Nextcloud sources, you have two options.
You can use the stable version.
Or, you can use the development version from GitHub.
To check out the source from GitHub, you'll need to install Git.
Take a look at this: What Do People Use Other than Nextcloud
Git Sync - Mirror Repo as Folder
The Git Sync tool allows you to mirror a GIT repository as a read-only folder on nextCloud. This is exactly what The GMU did, mirroring their GIT document folder with nextCloud.
The design is simple, but the implementation was more involved. For example, you can't just copy files from a GIT folder to the corresponding nextCloud folder because the file needs to be registered with the nextCloud database.
To mirror a GIT repo, the Git Sync tool updates nextCloud every minute with any new files or changes to the GIT repository.
The Git Sync tool has several requirements, including mirroring a GIT repo as read-only to a configured nextCloud user account. This ensures that the files in the GIT repository are not accidentally modified or deleted.
Here are the Git Sync requirements:
- Mirror a GIT repo as read-only to a configured nextCloud user account.
- All accidental uploads to the GIT folder are to be reverted to the GIT version of the file.
- A special transfer directory, ‘Transfer’, will allow uploads.
- Files transfered to the transfer directory from say a phone are to be moved to an appropropriate GIT folder in a timely fashion.
- Files transfered are purged weekly.
- Daily email report of all files processed for the day.
- Daily email of all errors processing files included in the daily email report.
- Configuration file management. Adding a repo per user can be accomplished by creating a new configuration file.
- Include and exclude directory options. The GIT repo directories can be filtered by using either an include or exclude list.
The Process
To successfully publish a new release via Nextcloud Git, you'll need to follow these steps. First, create a new release via GitHub, adding any relevant information you'd like to include.
Related reading: Nextcloud Migrate to New Server
You can choose whether this release is a normal or pre-release, which will determine whether it's uploaded as a nightly version to the App Store. If you decide on a pre-release, you can expect it to be treated as a nightly version.
Once you've completed the release, publish it and wait for a few minutes. You'll then receive a request to approve the release, which can be found in Actions or your notifications.
If everything goes smoothly, you should find an appname.tar.gz attachment waiting for you in the release. This is your newly compiled app, ready for distribution.
Broaden your view: Azure Devops Version Control vs Git
Featured Images: pexels.com

