Using Git

Configuring git for use with G-Cubed

When you have cloned a Github repository for a G-Cubed devcontainer and have opened a new devcontainer, you need to provide the git software with some configuration information about yourself. This can be done from the terminal in VS Code using the commands:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

You may also need to set the basic merge rules for branches. Do so at the terminal with the following command.

git config --global pull.rebase true

You may also need to set the auto remote branch setup configuration.

git config --global push.autoSetupRemote true

Learning to work with git

Table of contents

Git is a very powerful and popular version control system, widely used by software projects to manage their codebase. It helps users to track and share their changes as they work on their project.

Git tracks how the text files in a project evolve by providing a history of all the changes made to the them. Every time changes are saved, Git creates what is known as a commit, representing the state of all project files at the point in time that the commit was created.

G-Cubed projects are built on a Git foundation. Git is used to manage the development of all G-Cubed software and all G-Cubed models. Specific research projects are simply new model development projects and they too benefit from being set up with a Git foundation.

Github is a commercial website that hosts a staggering number of software development projects that also use Git for version control. G-Cubed uses Github to host its projects. At its core, this means that the central repository for all G-Cubed projects is hosted by Github. It also means that those projects benefit from all of the additional features provided by Github, including code review systems, issues tracking, project management, Wiki documentation, and so on.

Git is extremely powerful and that power implies a learning curve. To become an efficient contributor to G-Cubed projects, team members need a minimum level of understanding about how to use Git. Fortunately, the VS Code editor used for working with G-Cubed projects has great built-in support for Git that makes it easy to do the common Git operations. VS Code also has extensions like Git Graph that make it easy to visualise the state of a project. Git Graph is built into the devcontainers used for G-Cubed projects.

VS Code also provides an excellent user interface to work with git without relying on running git commands in the VS Code terminal. This interface is accessed via the following icon on the left-hand side of VS Code when a devcontainer has been opened.

Git Button in VS Code

The VS Code team provides detailed instructions on how to work with their git UI.

Ways to learn Git

It is often tempting to just get started and figure things out as you go. While this is possible with Git, it is not encouraged, even for small projects. There is a conceptual framework that needs to be understood before the various Git operations make sense. The following resources provide different ways of developing this understanding. It is worth exploring them until that conceptual framework is understood.

Github workflows

Git is all about making it ‘easy’ to collaborate across large teams all working on the same collection of text documents, supporting independent work, contribution sharing, and conflict resolution. Many different workflows have evolved as teams determine how they can best use Git for their own collaboration.

Github has documented a workflow that we also recommend for G-Cubed projects. It encourages particular patterns when using Git that quickly become familiar.