Last active
May 30, 2025 04:24
-
-
Save mabarbeau/fa914015b0f6a72c062f100f2baf8d71 to your computer and use it in GitHub Desktop.
A `git rebase` that auto resolves conflicts in yarn.lock
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
rebase () { | |
if [ $# -ne 0 ]; then; | |
locks=$(find . -name "yarn.lock" -not -path "./node_modules/*" -not -path "*/node_modules/*" | tr '\n' ' ') | |
output=$(git rebase $@) && echo $output | |
if echo $output | grep 'CONFLICT' | grep -q 'yarn.lock'; then | |
echo -e "\n\033[4;33mConflicts found in yarn.lock\n\033[0m\033[2;20mAuto merging\033[0m\n" \ | |
&& git checkout $1 -- $(echo $locks) \ | |
&& yarn install \ | |
&& git add $(echo $locks) \ | |
&& echo -e -n "\n\033[6;32mConflicts in yarn.lock resolved\!\n\033[0m\033[2;20mContinue with \`\033[0m" \ | |
&& echo "git rebase --continue\`\n" | |
fi | |
else | |
git rebase $@ | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use like
git rebase
e.g.