Branches

The main branch (the default branch when you do a simple Git clone) is used for development, with other branches being used to maintain stable versions. Each stable branch is usually created just before the main branch is declared stable, because that is when some people start working on the next unstable development phase.

GNOME tries to use the same Git branch names for all core modules. The following rules are used for branch names:

  • Use only lowercase characters.

  • Use hyphens rather than underscores.

  • Use the format “gnome-VERSION” for the branch name if your branch is targeted for a new major release. Including the module name or the word “branch” is not necessary.

For example, gnome-45 would be an excellent choice for a branch name targeting the GNOME 45 release.

Example

Here’s an example, when branching for 45 (inside a clone of the module!):

git branch gnome-45 main
git push origin gnome-45
git branch -d gnome-45
git checkout -b gnome-45 origin/gnome-45

Where origin is the local name for the GNOME Git repository. The last two commands are to ensure that the local branch is properly setup to track the remote branch.

If you forgot to branch and want to use an older commit for branching, for example to have the last 3 commits in main not included in your new gnome-45 branch, use HEAD~x (where x stands for the number of latest commits to exclude from your new branch) instead of main:

git branch gnome-45 HEAD~3
git push origin gnome-45

A shorter way to create a new remote branch and track it within a local branch is (using a fully qualified ref spec):

git push origin origin:refs/heads/gnome-45
git checkout -b gnome-45 origin/gnome-45

To delete a faulty remote branch use:

#potentially dangerous!
git push --delete origin gnome-45

If unsure, use the --dry-run option for git push first.