-
-
Save krvajal/657fa1cc0ccd161424d1a387108f7e61 to your computer and use it in GitHub Desktop.
Steps for merging an old branch into a newly prettier-ified codebase. Use at your own risk, verify everything was correctly merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assumes 3 sequential commits: | |
# | |
# 1. commit tagged "prettier-before" that added `prettier` depedency and `prettier` script your package.json | |
# 2. commit that actually ran `prettier` on your entire codebase for the first time | |
# 3. commit tagged "prettier-after" that fixes any minor issues caused by prettier (e.x. moving eslint-ignore or $FlowFixMe comments around), or just the next commit if there were none | |
# | |
# I recommend running these as individual commands, not as a script, in case of merge conflicts | |
# In the sweepbright app this commits have the following hashes | |
# $prettier-before ๐ 352f43227d9ae5de0de92b48158d0f02feb7588c | |
# $prettier-after ๐ 5330ac90e7adf6f0867228680686f6aaedd8b065 | |
# Checkout the non-pretty branch you want to merge | |
# (or optionally make a new branch with `git checkout -b $YOUR_BRANCH-prettier $YOUR_BRANCH`) | |
git checkout $YOUR_BRANCH | |
# Merge the commit immediately prior to running prettier globally: | |
git merge 352f43227d9ae5de0de92b48158d0f02feb7588c | |
# Manually resolve conflicts if necessary, then commit if necessary | |
# Save a list of changed files between that commit and your branch pre-prettier as a sanity check | |
git diff --name-only prettier-before > prettier-before.diff | |
# Update the dependencies and run `prettier` on your branch: | |
yarn | |
yarn run prettier | |
# Commit the results | |
git commit -a -m "Run prettier on $YOUR_BRANCH" | |
# Cherry-pick the commit after you ran prettier | |
git cherry-pick 5330ac90e7adf6f0867228680686f6aaedd8b065 | |
# Then merge with same commit | |
git merge -Xours 352f43227d9ae5de0de92b48158d0f02feb7588c | |
# Merge with master (or any commit after `prettier-after`): | |
git merge develop | |
# Run lint/flow/tests, if applicable | |
yarn lint && yarn flow && yarn test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment