GitHub @ Trimble

The home of onboarding and contribution guidelines for Trimble GitHub users of all stripes: open source, inner source and projects for specific internal teams.

View on GitHub

Contributor Guidelines

Make sure you have first read and followed the instructions in the README.

This includes making sure that you’ve sent your request to join the Trimble GitHub Enterprise and that you have successfully logged in to your GitHub account. Otherwise, creating a PAT will fail.

Contributor GitHub Access Configuration

Contributor Setup

[user]
    email = my_name@trimble.com
    name = Your Full Name

Edit your global user .gitconfig

[includeIf "gitdir:~/work/trimble/**"]
    path = ~/work/trimble/.gitconfig

[pull]
    ff = only

[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true

Recommended: VS Code is a wonderful editor for git commits, merges and diffs. If you use VS Code it is recommended to add these additional sections to your global user ~/.gitconfig

[core]
    editor = code --wait -n
    autocrlf = input

[merge]
    tool = code

[mergetool "code"]
    cmd = code --wait $MERGED

[diff]
    tool = code

[difftool "code"]
    cmd = code --wait --diff $LOCAL $REMOTE

How to Fork

Create a Fork

Create a Fork of the primary repository (https://github.com/trimble-oss/{repository-name}) you will be contributing to. Click on the Fork button on the top right of that page in your browser when on the GitHub website.

Clone your Fork Locally

From a command line, clone your forked repository to your ~/work/trimble folder. For example, https://github.com/github-user-name/{repository-name}.

Note - do not clone the primary repository. Clone your fork.

> cd ~/work/trimble

> git clone https://github.com/github-user-name/{repository-name}
Cloning into '{repository-name}'...
remote: Enumerating objects: 126, done.
remote: Counting objects: 100% (126/126), done.
remote: Compressing objects: 100% (89/89), done.
remote: Total 126 (delta 53), reused 100 (delta 30), pack-reused 0
Receiving objects: 100% (126/126), 5.42 MiB | 15.38 MiB/s, done.
Resolving deltas: 100% (53/53), done.

> cd {repository-name}

> git remote -v
origin	https://github.com/github-user-name/{repository-name} (fetch)
origin	https://github.com/github-user-name/{repository-name} (push)

Note at this point that origin represents your fork. Next we’ll add the primary repository as a remote called upstream.

Connect upstream to the Primary Repository

Add the primary repository as a remote named upstream and be sure to use HTTPS (not SSH). Your output should look like the following (except the origin remote should refer to the fork for your GitHub user name.

> git remote add upstream https://github.com/trimble-oss/{repository-name}
> git remote -v
origin	https://github.com/github-user-name/{repository-name} (fetch)
origin	https://github.com/github-user-name/{repository-name} (push)
upstream	https://github.com/trimble-oss/{repository-name} (fetch)
upstream	https://github.com/trimble-oss/{repository-name} (push)

Working with Forks

Synchronizing main

Contributors will perform all of their work, create commits, and manage branches in their own forks. Once a contributor has verified their work meets all contribution standards for a given project, they may submit a Pull Request (PR) to a branch in the primary repository (typically targeting main but possibly a different branch in some special cases).

A common command flow when working with forks looks like this:

> git fetch upstream
...
> git checkout main
...
> git pull upstream main
...
> git push origin main
...

The git fetch upstream command brings any changes from a remote (upstream in this case) to the local machine. You can fetch any time you want and it will not impact what you are currently working on.

Running git checkout main will checkout your local main branch. It’s typicaly good practice to make sure you do not have any uncommitted changes before checking out main (or any other branch, for that matter).

The git pull upstream main command will take any fetched changes from upstream/main and apply them to your local main branch.

Finally, running git push origin main will ensure that your origin/main fork has the latest changes from the primary repository applied to its main branch.

Rebasing

Merge commits are generally not allowed in the main branch in the primary repository. This requires contributors to rebase their branches to ensure a clean, concise and consistent commit history.

Explaining rebasing is beyond the scope of this document. However the following resources explain how rebasing works and how to rebase your own branches:

Git Remote configuration - HTTPS vs SSH

Additional notes