Git workflow for large linting commits

When there are big linting changes to bring into working branches, the team can experience many painful merge conflicts.

The idea here is to resolve conflicts manually up the point before the linting commit. Then automatically pick the working branch’s changes for the conflicts from the linting changes. You don’t want to auto-pick a branch for merge-resolution outside of the commits related to linting.

git fetch
export LINT_COMMIT=<THE_GIT_COMMIT>

# merge changes up to commit before the linting change, resolving conflicts carefully
git merge $LINT_COMMIT~
# fix conflicts and commit
bundle

# Merge all the linting changes, always picking your working branch when conflicts, skipping the lint fixes.
# If your linting change is several commits, use the last one here.
git merge -Xours $LINT_COMMIT

bundle

# fix changes on your working branch
bin/lint
git commit -m "lint autofixes"
# do manual lint fixes
git commit -m "manual lint fixes"
git merge origin/master

If you want to rebase, you can use git rebase -Xtheirs $LINT_COMMIT

Note that the merge strategies of ours and theirs switch depending on merge vs rebase.

1 Like