/ Tech

GWS - Git Workspace

Have you ever used Git submodules? Then you know the pain they bring... If you just want to keep some Git repos together organized, then GWS - Git Workspace is for you!

UPDATE: See How VSHN manages Hiera data files for an example use case.

Just write your repo references in a simple file called .projects.gws and call gws update. This will clone the referenced repos and gives you some other nice helpers.

A sample .projects.gws could look like this:

# Puppet modules
stdlib    | https://github.com/puppetlabs/puppetlabs-stdlib.git
apache    | https://github.com/puppetlabs/puppetlabs-apache.git
apt       | https://github.com/puppetlabs/puppetlabs-apt.git

(lines beginning with a # are comments).

GWS gives you even more:

  • init - Detect the repositories and create the projects list
  • update - Update the workspace to get new repositories from projects list
  • status - Print status for all repositories in the workspace
  • fetch - Print status for all repositories in the workspace, but fetch the origin before
  • ff - Print status for all repositories in the workspace, but fast forward from origin before
  • check - Check the workspace for all repositories (known/unknown/missing)

The cloned repos are normal Git repos in which you can do whatever you want with git, without fearing to break any Git submodules or subtree magic.

If you chose to save this carefully crafted .projects.gws in it's own repo, then add the following .gitignore to this repo:

# Ignore everything, so all repositories in our case
# But not these files