Skip to content

Instantly share code, notes, and snippets.

@justjanne
Last active March 15, 2024 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justjanne/47d64d05bdaad3322c261761000d85c2 to your computer and use it in GitHub Desktop.
Save justjanne/47d64d05bdaad3322c261761000d85c2 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
conflicts=$(git status --porcelain | grep UU | cut -d ' ' -f 2)
for conflict in $conflicts; do
cat $conflict | \
tr '\n' '\r' | \
sed -E 's/<<<<<<< [^\r]*\r((import[^\r]*\r)*)=======\r((import[^\r]*\r)*)>>>>>>> [^\r]*\r/\1\2\3\4/g' | \
tr '\r' '\n' | \
tee $conflict > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment