Skip to main content

Resolve merge conflicts

Pretty often when opening a pull request it is very likely to run into merge conflicts as the release process is generally updating npm-shrinkwrap.json.

To better illustrate the commands listed here at will use commits and screenshots from open-sauced#1078.

Repository setup

Fork and clone the project using the gh command line interface:

gh repo clone 0-vortex/open-sauced

Running git remote -v will output:

origin (fetch)
origin (push)
upstream (fetch)
upstream (push)

Fork and clone the project using the git command line interface:

git clone

Running git remote -v will output:

origin (fetch)
origin (push)

As an additional step for this tutorial, we need to add the upstream remote:

git remote add upstream


First, get the default branch changes:

git fetch origin --recurse-submodules=no --progress --prune
git checkout main --
git fetch upstream --recurse-submodules=no --progress --prune
git merge upstream/main --no-stat -v

Merge with upstream

Then merge with the forked up-to-date beta (default branch):

git merge origin/main --no-ff -v

You will see something similar to:

proper merge but results in conflicts

Review changes

To see what the changes are do a:

git diff package.json

It will look like this:

review merge conflicts

Resolve conflicts

Since this pull request does not modify the package.json file it is safe to fast-forward the changes from origin/main:

# overwrite with origin/main changes
git show :3:package.json > package.json

A more traditional way of doing the same thing is:

# make a local copy of all changes and use --theirs
# --theirs strategy overwrite with origin/main changes
git show :1:package.json > base.package.json
git show :2:package.json > branch.package.json
git show :3:package.json > head.package.json
git merge-file -p --theirs \
branch.package.json base.package.json head.package.json > package.json

Commit changes

Not making any assumptions about editor preferences running this will open the configured editor with a default commit message:

git commit

That should look like this:

commit merge message

Push updated pull request

One more security check to make sure your branch has not diverged and push:

git status
git push

It should look something like this:

push updated pr

Review your pull request

The result of the above commands can be viewed at 283ff8cd788c550309ff0d1d5a9a5a97ec0731b2

GitHub will conveniently display only your merge conflict changes:

view merge commit

And it's ready to merge:

ready to merge

Dependency updates

When dealing with dependency and lock file updates, there are multiple use cases to consider; however, as a baseline, the OpenSauced triage team will not prioritize parallel main features as seen in the roadmap.

However when that happens, it is advised to:

  • fast-forward npm-shrinkwrap.json
  • fast-forward deleted and modified upstream/beta changes to package.json
  • fast-forward your added lines to package.json
  • run npm ci to delete local modules and create dependency resolution from upstream/beta

Visual diffing is advised; however, not following the git commit history procedure will result in a rogue pull request that creeps into dependency updates.

Generally speaking, just adding things to a lock file will not be troublesome, and since this is a licensed project, we should be careful when adding dependencies.