Mozilla: A git workflow for Gecko development

Mike Hommey edited this page Sep 7, 2018 · 9 revisions

Here is my recommended setup for Gecko development with git:

  • If you're on macOS you should just use the homebrew version of git-cinnabar. It will work out of the box. Otherwise you might run into python sadness. (Unsupported bundle version...)
  • Install mercurial (only needed for its libraries). You probably already have it installed. Eventually, this dependency will go away, because the use of mercurial libraries is pretty limited.
  • Install git-cinnabar (see the Setup section in the README—essentially just clone it somewhere, put the path to your local clone in your PATH, then install the native helper).
  • Clone the mozilla-unified repository:
$ git clone hg:: gecko && cd gecko

If you are using git-cinnabar version 0.5.0b4 or newer, you can also try the following for a faster clone (albeit, larger on disk and network transfer):

$ git -c cinnabar.clone= clone hg:: gecko && cd gecko
  • Set fetch.prune for git-cinnabar to be happier:
$ git config fetch.prune true
  • Assuming you have watchman installed, as well as git >= 2.16, set up your local git hook to make git status and friends faster:
$ mv .git/hooks/fsmonitor-watchman.sample .git/hooks/query-watchman
$ git config core.fsmonitor .git/hooks/query-watchman

With this setup, you can e.g. create new topic branches based on the remote branches:

$ git checkout -b bugxxxxxxx origin/bookmarks/central

When you're ready to test your code on try, you can use the mach try command, or, if you want to do things manually, setup a remote for the try server:

$ git remote add try hg::
$ git config remote.try.skipDefaultUpdate true
$ git remote set-url --push try hg::ssh://
$ git config remote.try.push +HEAD:refs/heads/branches/default/tip

then create a commit with the try syntax, and do:

$ git push try 

This will push whatever your checked-out branch is, to the try server (thanks to the refspec in remote.try.push).

When you're ready to push to an integration branch, remove any try commit. Add a remote for the integration branch. Example for mozilla-inbound:

$ git remote add inbound hg::ssh://
$ git config remote.inbound.skipDefaultUpdate true
$ git config remote.inbound.push +HEAD:refs/heads/branches/default/tip

Rebase your changes on top of inbound:

git rebase --onto origin/bookmarks/inbound @{upstream}

Then push to the integration branch. Assuming the inbound setup from above:

$ git push inbound

If you need to rebase again because someone else won the push race, use:

$ git fetch
$ git rebase origin/bookmarks/inbound

But, this is only one possibility. You're essentially free to pick your own preferred workflow. Just keep in mind that we generally prefer linear history on integration branches, so prefer rebase to merge (and, git-cinnabar doesn't support pushing merges yet). I'd recommend setting the pull.ff configuration to "only", by the way.

Please note that rebasing something you pushed to e.g. try may leave dangling mercurial metadata in your git clone. git cinnabar fsck will tell you about them, but won't do anything about them, at least currently. Eventually, there will be a git-gc-like command.

Please report any issue you encounter in the comments, or, if they are git-cinnabar related, on github.

Other Tips

Checking out a changeset from try:

$ git cinnabar fetch hg:: <changeset>


$ git cinnabar fetch try <changeset>

if you have set up a try branch.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.