Git and Github: Commits, Merges, PRs and more

Here is a roundup of all the best practices, policies and processes for collaborating as a team with git, Github and updates.

Use Semantic Versioning

According to semver.org, semantic versioning follows this convention: MAJOR.MINOR.PATCH

  1. MAJOR version when you make breaking changes
  2. MINOR version when you make additions that are backwards compatible
  3. PATCH (aka BUG) when you make backwards compatible
  4. [Optional] HOTFIX when you just need something to get fixed and go live as fast as humanly possible
    • This should be used incredibly sparingly and with strongly justified reasoning.

It is worth noting that a repo’s package.json and style.css versions may be out of sync. Updating packages, even if the package itself contains a breaking change, may not always result in a change to the theme code. Similarly, updating packages may not even necessarily warrant updating the theme’s PATCH version.

Create new branches from the default branch

Obviously, there will be times when this doesn’t apply, but as a general rule, all branches (regardless of semver number) should start from the default branch (often called main, sometimes called master).

Pull Requests

As of July 1, 2025, pull requests should always be regular merge commits until merging into main/master, in which case they should probably be squash commits.

Order of Operations

Branches should be merged into dev, up through stg and finally to main. Once code is committed to dev, it’s on a Senior Web Developer to take the feature live to main. Before any merging happens, the dev branch should be reset to match where the main branch is at.

Make sure to drop a message in the #webdev Slack channel to make sure this is good to go!

Command Line Process

Note: branch names are assumed to be dev and main, respectively, but this may not always be the case across every repo.

  1. Fetch the latest updates: git fetch origin
  2. Check out the dev branch locally: git switch dev
    • If you don’t have a local dev yet: git checkout -b dev origin/dev
  3. Reset dev to match origin/main exactly: git reset --hard origin/main
    • This makes your local dev branch match origin/main completely.
  4. Force-push the cleaned dev back to GitHub: git push origin dev --force
    • This overwrites origin/dev to match origin/main.

VS Code GUI Process

Step 1: Sync your dev and main branches (spinner icon)

Step 2: Switch to your dev branch

Step 3: Open your CLI and type the following:

git reset --hard origin/main

Once you do this, your dev branch may have some code changes to pull down. Do not sync them up as that will undo what you just did.

after resetting the dev branch, leave these changes alone!

Step 4: Continuing in your command line, force push the changes up to Github

git push origin dev --force

You can confirm this worked by going to the dev branch on Github and you should see the following message: “This branch is up to date with main“.

See something inaccurate?