Last active
May 31, 2022 11:18
-
-
Save pokey/748ba17a2b7ee88c884992e477632ebb to your computer and use it in GitHub Desktop.
A bash script to merge the recent knausj reformat
This file contains 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
# ============= Notes ===================== | |
# This script contains the commands I ran to merge my Talon files (https://github.com/pokey/pokey_talon/) | |
# with the recent large reformat that took place in knausj (https://github.com/knausj85/knausj_talon/commit/3bf4882fa0a05b22171e59118bd7c9640aae753a) | |
# You can use this script for inspiration when you perform the merge on your own talon files. | |
# Note that this script is not meant to be run exactly; it is just a guideline. | |
# I'd recommend reading through and modifying each step to fit your individual setup | |
# Your mileage may vary | |
# ============= Initial setup ============= | |
# Clone and cd into a fresh knausj just to use for the merge | |
git clone '[email protected]:knausj85/knausj_talon.git' knausj_talon_staging | |
cd knausj_talon_staging | |
# Add and fetch your remote (replace `pokey` with your own repo here) | |
git remote add pokey '[email protected]:pokey/pokey_talon.git' | |
git fetch pokey | |
# Checkout your remote branch; replace with your own branch name / repo name | |
git switch -c pokey-main pokey/main | |
# =============== Step 1 ================= | |
# First, we will merge up until the last change before the big reformat commit | |
# We are using git-imerge (https://github.com/mhagger/git-imerge) | |
# Can replace with a normal `git merge` if you prefer | |
# -------------------- | |
# Start the merge | |
git-imerge merge d5696b0f7f7d8e0e30dd47e3bad71badae0d0be8 | |
# Proceed through the merge process, resolving and adding any conflicts | |
# If you're using imerge above, you'll need to repeatedly issue | |
# | |
# git-imerge continue | |
# | |
# after each time you resolve / stage / commit | |
# Then, if you're using imerge, once you're done you issue | |
git-imerge finish | |
# ================== Step 2 ================== | |
# We are now merged with everything up to right before the reformat commit. | |
# Now we are going to get a bit tricky to handle the actual reformat commit. | |
# The idea is to just take our side of the merge, ignoring the reformat commit, | |
# then run pre-commit to do all the formatting, and commit it. This way we don't | |
# actually need to resolve any merge conflicts, but we get the same result. | |
# | |
# Note that others have recommended replacing this step with instead creating | |
# your own commit which runs pre-commit at this stage, then merging with the | |
# knausj reformat commit, so that you can look at any conflicts to see if they | |
# are sensible. That would allow you to detect differences in the way pre-commit | |
# runs locally on your machine | |
# ------------------ | |
# Start merging with the reformat change, but don't commit anything, because we don't actually | |
# want to keep the files that git creates for us. We use a regular merge here because we | |
# don't need anything fancy, as we'll be hacking a bit | |
git merge --no-commit 3bf4882fa0a05b22171e59118bd7c9640aae753a | |
# Clear out the git working directory, and just replace it with our files (replacing pokey-main | |
# with your branch) | |
git rm -rf . | |
git checkout pokey-main -- . | |
# Now just run pre-commit on all of our files | |
pre-commit run --all-files | |
# Then add the files and commit them | |
git add . | |
git commit | |
# =============== Step 3 ================== | |
# We have now reformatted our files, and told git that we are up-to-date with the | |
# reformat commit. We will proceed to merge the rest of the commits after the reformat | |
# --------------- | |
# Feel free to use a regular merge if you prefer | |
git-imerge merge master | |
# Now proceed with merge as usual, using `git-imerge continue` if you're doing an imerge | |
# Finish the merge if using `imerge` | |
git-imerge finish | |
# ============= Step 4 ================ | |
# We now have a local branch called `pokey-main`, which has our merged code! | |
# We just need to push it to our repo and then pull it from our actual talon user files | |
# --------------------- | |
# Perform the push, replacing `pokey` with whatever you're using for your remote, | |
# `pokey-main` with whatever you're using for the local branch name we have been using, | |
# and `main` with the branch you use for your main talon files | |
git push pokey pokey-main:main | |
# Finally, in your regular user files, pull your new results (replace `pokey_talon` with whatever you use) | |
cd ~/.talon/user/pokey_talon | |
git pull | |
# All done! You may want to restart Talon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment