Version Control (Git)
With AI agents coming onto the scene, your team is getting bigger and websites are being updated by more and more people. CLI 2.0.0 is fully integrated with git, the most popular version-control tool, so if two people update the same file, it will take care of the changes for you!
Written By Matt Jones
Last updated About 1 hour ago
Pre-requisites
Git support is a major update for CLI versions > 2.0.0
About git and GitHub
Version control is a concept that developers use to keep track of different versions of software. Rather than creating files with increasingly long names e.g. “final-final-final.doc” developers have found it helpful to have professional tools.
git is a market-leading open source tool for version control
https://github.com/ owned by Microsoft, implementing git, allows you to store your git repositories in the cloud and share with your team (or the open source community).
You can use Siteglide CLI’s version control integration with git alone. Connecting to a remote repo on GitHub is optional. If you do want to connect to a remote, you’ll need your own account.
Setup
When you work on a Siteglide project via the CLI, it’s strongly recommended that you initiate your project folder as a git repository.
You can do that by running the pull command:
siteglide-cli pull <env>This will ask you a few new one-time questions about your preferences and store them for you.
It will also ask you if you want to setup your project as a git repository. Type y !
It will copy a prompt to your clipboard, which you can paste into AI chat. AI can then complete the setup for you, checking in real time your current computer’s situation e.g. checking what you have already installed.
If you don’t use the AI route, here’s a quick list of things to do:
Install git and add to PATH
change directory
cdgit initgit add .git commit -m “initial commit”siteglide-cli pull <env>- Pulling the site again now creates a clear baseline where the remote site and your local code are the same. See pull below.Optional - Connect to remote
Source of Truth
The first time you pull, the CLI creates .siteglide/project/sourceOfTruth.json. It tells the CLI where the latest version of your code lives, so it knows whether to check the site for changes before it overwrites anything. Commit this file so everyone on the project uses the same setting.
site (the default) is for a standard Siteglide website. The site is the source of truth, because colleagues and clients may also change code or content in Siteglide Admin or Studio. You pull their changes from the site, then sync or deploy your work, and the CLI checks the site for newer files before it uploads.
versionControl is for projects where Git is always the source of truth and nobody edits in Siteglide Admin, such as a module or a platformOS site hosted on Siteglide. You work on branches and pull requests, then sync or deploy from a branch when you're happy. The CLI skips the site checks (as if you'd used
-s) and asks you to confirm before pulling from the site.
To switch, change the sourceOfTruth value in the file to site or versionControl. You can also run siteglide-cli ai with no environment to choose the setting and set up the Siteglide MCP without pulling from a site.
Pulling the Site
siteglide-cli pull <env>With Git set up, pull no longer overwrites your files. Choose Pull and merge and the CLI will:
commit any uncommitted work first, asking you for a commit message
pull the site onto a temporary branch
merge it back into your branch
If you and someone on the site changed the same lines, you'll get normal Git merge conflicts, and the CLI offers a prompt for your AI assistant to help resolve them. Check what it kept, then git add the resolved files. The CLI commits the merge for you once everything is staged.
Each pull records a baseline: the point where your local code and the site match. Sync and deploy use it to tell whether someone has changed the site since you last pulled. If your project already had Git history before CLI 2.0, the first pull and merge can be one larger merge while that baseline is set up.
Pull won't run while your files have unresolved conflict markers. Without Git, pull works the old way and overwrites your local files after you confirm. Add -s (--skip-remote-check) to get that simple behaviour on a Git project too.
Deploying the Site
siteglide-cli deploy <env>Deploy sends your whole codebase to the site in one go. Add -w (--with-assets) to include your assets folder, such as CSS and JS.
Before it uploads, deploy checks the site for files changed since your last pull. If it finds any, choose Merge and deploy (recommended). It pulls to a temporary branch and merges, then carries on deploying once any conflicts are resolved and staged. Without Git, your only options are to deploy anyway, which may overwrite changes on the site, or to cancel.
When you deploy to production with uncommitted changes, deploy offers to commit a snapshot of your code first, so you have a record of what went live.
Deploy won't run while your files have unresolved conflict markers, or while you're on one of the CLI's temporary merge branches. Use -s to skip the site check, for example in CI or when you mean to overwrite the site.
Syncing the Site
siteglide-cli sync <env>Sync watches your project and uploads each file when you save it. Before each upload, it checks whether that file on the site is newer than your last pull. If it is, sync pauses and asks what to do:
Merge and sync (with Git) commits your work, pulls to a temporary branch and merges. Resolve any conflicts with your AI assistant and stage them, and sync uploads automatically. You don't need to save the file again.
Sync (without Git) uploads anyway for this save, which may overwrite the newer version on the site.
Cancel sync stops for now, so you can pull first.
Sync also pauses while your files have unresolved conflict markers. Use -s to skip the site checks.
Two things aren't covered yet. Binary assets such as images aren't checked for conflicts (CSS and JS are), so take care when two people change the same image. Deleted or moved files can also come back: if someone with an old copy syncs a file you've deleted, the CLI treats it as a new file. Pull after big moves and ask your team to do the same.
Was this helpful?
More in CLI
Quickstart: CLIIntroduction to the Command Line Interface (CLI)About CLICLI Site SetupStill need help? Ask the team