Created
April 7, 2016 16:52
-
-
Save wpalmer/9c2aa7907ebbcd096e2df0625176f813 to your computer and use it in GitHub Desktop.
written but not run - merge a single file
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
#!/bin/bash | |
TEMP="$(mktemp --tmpdir -d 'git-merge-single.XXXXXXXXXX')" | |
[ -n "$TEMP" -a -d "$TEMP" -a -w "$TEMP" ] || exit 1 | |
_cleanup(){ rm -rf "$TEMP"; } | |
trap _cleanup EXIT | |
their_commit="${1%%:*}" | |
file="${1#*:}" | |
git cat-file blob "$their_commit:./$file" > "$TEMP/theirs" | |
git cat-file blob "$(git merge-base HEAD $their_commit):./$file" > "$TEMP/base" | |
git merge-file "./$file" "$TEMP/base" "$TEMP/theirs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment