gws

A helper to manage workspaces composed of git repositories.

Download as .zip Download as .tar.gz View on GitHub

gws

gws is a KISS, bash, colorful helper to manage workspaces composed of git repositories.

SHOW ME PICTURES!

Here are some screen captures of gws:

gws

gws

gws

gws

gws

Installation

Requirements: git, bash > 4.0

On a side note, I could also suggest you to have a look at peru which permits to keep files from different sources up to date with one command.

QuickStart

or

and then

But better

Let's say you made a ~/dev/ workspace folder and you created your .project.gws list in it. Then your workspace became really easy to replicate! Just make this ~/dev folder a git repository, add two files and commit them: .projects.gws and the following .gitignore:

# Ignore everything, so all repositories in our case
*

# But no these files
!.projects.gws
!.gitignore

Now, when you need to get your workspace on another computer, just clone the dev repository, for instance again to the ~/dev folder. Go into it and do a gws update. Everything is cloned and ready to be hacked!

You want to add a new project into your workspace? Add it to the .projects.gws list, do a gws update to get it. Then commit and push the .projects.gws file, so when you arrive at work for instance, you just need to do git pull on the ~/dev folder and then gws update to find the same workspace structure that you where having at home.

Why?

If you are, like me, a Linux programmer/hacker/coder who uses heavily git, you certainly have a directory in your home folder named dev, workspace, code or something else that contains all the projects you are working on. For instance my current organisation is:

dev
├── archlinux
│   ├── aur
│   └── habs
├── perso
│   ├── gws
│   ├── imaxplore
│   └── teafree
├── config

where aur, habs, gws, imaxplore, teafree, config are git repositories.

Since I use at least three different computers, one laptop, one at home and one at work, I like to have the same folder structure on all of them. Of course remembering which project was added recently on others computer and in which folder is tedious.

So I started to thing about using git submodules to register all projects on which I am working and syncing them with git between the two computers. But clearly git submodules are not usable because they are working on specific commit and are not following branches.

No worry. The problem is pretty trivial, so I decided to start write a little bash (YOLO) script that read a simple list of repositories, and clone them if they don't exist. And then, commit by commit, the script as grown to finally become a helper to sync, monitor and check workspaces.

I thought it can be useful to other people, so I made a little cleanup, write a small documentation, and there it is. I hope you will enjoy it!

Functionalities

This tool offers some functionalities, among which:

Syntaxes

.projects.gws

One project per line. Must be of the form:

<any/folder/path> | <remote_url1> <remote_name1> [ | <remote_url2> <remote_name2> [ |  ... ]]

knowing that:

.ignore.gws

One regular expression per line. The regular expression will be matched to projects name. Some examples:

This function is really usefull for ignoring locally some projects that are not needed nor accessible.

Other thoughts

Future

This project aims to stay simple. I will try to keep the project as alive as possible for a bash script, by correcting bugs and maybe some improvements. Also, maybe one day, if I have time, I will rewrite all this script in python or other more maintainable language.

Edit: It seems there will be a continuation of this idea, and it will be written in OCaml! I'll let you know if the project maturate! In any case this project will stay here for users who want something simple and portable.

Contributors

Many thanks to these people for contributions: