Skip to content

Instantly share code, notes, and snippets.

@adamschlesinger
Created December 17, 2021 17:54
Show Gist options
  • Save adamschlesinger/50d1e1266b50abb2876769577b18869f to your computer and use it in GitHub Desktop.
Save adamschlesinger/50d1e1266b50abb2876769577b18869f to your computer and use it in GitHub Desktop.
Hacky script for helping with extensive rebases if you primarily only care about the changes from the current branch
#!/bin/bash
current_status=$(git status)
handleRebaseStatus() {
local status_string=$1
local git_resolution=$2
paths_to_resolve=$(echo "${current_status}" | pcregrep -o2 "(?<=${status_string}:)(\s*)(.+)")
echo "RESOLVING \"${status_string}\""
for path in $paths_to_resolve
do
git "${git_resolution}" "${path}"
done
}
handleRebaseStatus "added by us" "rm"
handleRebaseStatus "deleted by us" "rm"
handleRebaseStatus "added by them" "add"
handleRebaseStatus "deleted by them" "rm"
handleRebaseStatus "both modified" "add"
git rebase --continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment