Skip to content

Instantly share code, notes, and snippets.

@ninjapanzer
Created December 26, 2016 21:07
Show Gist options
  • Save ninjapanzer/a3a5ae848b1f5d6ba02f497224dca7f5 to your computer and use it in GitHub Desktop.
Save ninjapanzer/a3a5ae848b1f5d6ba02f497224dca7f5 to your computer and use it in GitHub Desktop.
Will provide interactive overwrite of diff between two branches
#!/usr/bin/env bash
CONFIGBRANCH=add_config_files
CURRENTBRANCH=`git symbolic-ref --short -q HEAD`
TMPPATH=tmp/config
rm -r $TMPPATH
NAMES="`git diff --name-only $CURRENTBRANCH $CONFIGBRANCH`"
for name in $NAMES
do
if [ "$name" != ".gitignore" ]
then
#git checkout add_config_files -- $name
mkdir -p $TMPPATH/`dirname $name`
git show $CONFIGBRANCH:$name > $TMPPATH/$name
fi
done
for name in $NAMES
do
if [ -f $name ]
then
DIFF=`diff $TMPPATH/$name $name`
if [[ $DIFF ]]
then
tput setaf 1; tput bold;
echo "File $name Already Exists in Project"
tput setaf 4;
diff $TMPPATH/$name $name
tput sgr 0;
cp -i $TMPPATH/$name $name
fi
else
tput setaf 1; tput bold;
echo "File $name Copied"
tput sgr 0;
fi
done
tput sgr 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment