Nextcloud Git Sync Tutorial for Beginners

Author

Reads 717

Detailed view of a black data storage unit highlighting modern technology and data management.
Credit: pexels.com, Detailed view of a black data storage unit highlighting modern technology and data management.

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

Credit: youtube.com, My GIT journey to contributing to Nextcloud Jessica Greene

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:

  1. Mirror a GIT repo as read-only to a configured nextCloud user account.
  2. All accidental uploads to the GIT folder are to be reverted to the GIT version of the file.
  3. A special transfer directory, ‘Transfer’, will allow uploads.
  4. Files transferred to the transfer directory from say a phone are to be moved to an appropriate GIT folder in a timely fashion.
  5. Files transferred are purged weekly.
  6. Daily email report of all files processed for the day.
  7. Daily email of all errors processing files included in the daily email report.
  8. Configuration file management. Adding a repo per user can be accomplished by creating a new configuration file.
  9. 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.

Git Sync - Mirror Repo as Folder

Credit: youtube.com, how to have a mirror git repo for your repos and updating them after every change in the main repo

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.

Credit: youtube.com, Building packages on GitHub -- a security risk? | Nextcloud Community Conference 2024

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.

Tiffany Kozey

Junior Writer

Tiffany Kozey is a versatile writer with a passion for exploring the intersection of technology and everyday life. With a keen eye for detail and a knack for simplifying complex concepts, she has established herself as a go-to expert on topics like Microsoft Cloud Syncing. Her articles have been widely read and appreciated for their clarity, insight, and practical advice.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.