Skip to content

Instantly share code, notes, and snippets.

@windviki
Forked from ecerulm/diffmerge-diff.sh
Created November 29, 2011 02:28
Show Gist options
  • Save windviki/1403095 to your computer and use it in GitHub Desktop.
Save windviki/1403095 to your computer and use it in GitHub Desktop.
Cygwin Git: wrappers for beyond compare, diffmerge and winmerge
#!/bin/sh
# Use BeyondCompare as difftool for git in cygwin.
# git config --global difftool.bc.cmd "beyondcompare-diff.sh \"\$LOCAL\" \"\$REMOTE\""
# git difftool -t bc branch1..branch2
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
library=~/gittool/githelperfunctions.sh
#[ -f $library ] && . $library
. $library
echo Launching BeyondCommpare - beyondcompare-diff.sh:
set_path_vars "$1" "$2"
echo "$beyondcompare" $localwinpath $remotewinpath
"$beyondcompare" "$localwinpath" "$remotewinpath"
#!/bin/sh
# Use SourceGear BeyondCompare as mergetool for git in cygwin.
# git config --global mergetool.bc.cmd "beyondcompare-merge.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
# git config --global mergetool.bc.trustExitCode true
# git mergetool -t bc
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
library=~/gittool/githelperfunctions.sh
#[ -f $library ] && . $library
. $library
echo Launching BeyondCompare - beyondcompare-merge.sh:
set_path_vars "$1" "$2" "$3" "$4"
echo "$beyondcompare" /lefttitle=Local /righttitle=Remote /centertitle=Base "$localwinpath" "$remotewinpath" "$basewinpath" "$mergedwinpath"
"$beyondcompare" /lefttitle=Local /righttitle=Remote /centertitle=Base "$localwinpath" "$remotewinpath" "$basewinpath" "$mergedwinpath"
#!/bin/sh
# Use SourceGear DiffMerge as mergetool for git in cygwin.
# git config --global mergetool.diffmerge.cmd "diffmergetool.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
# git config --global mergetool.diffmerge.trustExitCode false
# git difftool -t diffmerge branch1..branch2
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
library=~/gittool/githelperfunctions.sh
#[ -f $library ] && . $library
. $library
echo Launching DiffMerge.exe - diffmerge-diff.sh:
set_path_vars "$1" "$2" "$3" "$4"
echo "$diffmergewinpath" -t1=FROM_VERSION -t2=TO_VERSION --caption=$caption $localwinpath $remotewinpath
"$diffmergewinpath" -t1=FROM_VERSION -t2=TO_VERSION --caption="$caption" "$localwinpath" "$remotewinpath"
#!/bin/sh
# Use SourceGear DiffMerge as mergetool for git in cygwin.
# git config --global mergetool.diffmerge.cmd "diffmergetool.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
# git config --global mergetool.diffmerge.trustExitCode false
# git mergetool -t diffmerge
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
library=~/gittool/githelperfunctions.sh
#[ -f $library ] && . $library
. $library
echo Launching DiffMerge.exe - diffmerge-merge.sh:
set_path_vars "$1" "$2" "$3" "$4"
"$diffmergewinpath" --merge -t1=FROM_VERSION -t2=MERGED -t3=TO_VERSION --result="$mergedwinpath" --caption="$caption" "$localwinpath" "$basewinpath" "$remotewinpath"
unix2dos "$merged"
# From: http://rubenlaguna.com/wp/2010/08/05/visual-difftool-cygwin-git/
# From: http://gist.github.com/509918
# Helper functions
convert_path () {
file=$1
if [ "$file" == '/dev/null' ] || [ ! -e "$file" ]
then
file="/tmp/nulla"
`echo "">$file`
fi
echo `cygpath -w -a "$file"`
}
set_path_vars () {
local=$1
remote=$2
base=$3
merged=$4
echo ========= Cygwin paths =======
echo "LOCAL : $local"
echo "REMOTE : $remote"
echo "BASE : $base"
echo "MERGED : $merged"
localwinpath=$(convert_path "$local")
remotewinpath=$(convert_path "$remote")
basewinpath=$(convert_path "$base")
mergedwinpath=$(convert_path "$merged")
echo ========= Win paths =======
echo "LOCAL : $localwinpath"
echo "REMOTE : $remotewinpath"
echo "BASE : $basewinpath"
echo "MERGED : $mergedwinpath"
caption=`basename "$merged"`
beyondcompare="D:/Program Files/Beyond Compare/BComp.exe"
diffmergewinpath="D:/Program Files/SourceGear/DiffMerge/DiffMerge.exe"
winmergewinpath="D:/Program Files/WinMerge/WinMergeU.exe"
# diffmergewinpath=`cygpath -u C:/Program Files/SourceGear/DiffMerge/DiffMerge.exe`
# winmergewinpath=`cygpath -u \"C:\Program Files\WinMerge\WinMergeU.exe\"`
}
#!/bin/sh
# beyond compare for diff
git config --global difftool.bc.cmd "~/gittool/beyondcompare-diff.sh \"\$LOCAL\" \"\$REMOTE\""
#git difftool -t bc branch1..branch2
# diffmerge for merge
git config --global mergetool.diffmerge.cmd "~/gittool/diffmergetool.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
git config --global mergetool.diffmerge.trustExitCode false
#git difftool -t diffmerge branch1..branch2
git config --global alias.df "difftool -t bc"
git config --global alias.ci "commit --verbose"
git config --global alias.co "checkout"
git config --global alias.st "status"
git config --global alias.br "branch"
git config --global alias.rb "rebase"
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
git config --global alias.ls 'ls --show-control-chars --color=auto'
#!/bin/sh
# Use winmerge as mergetool for git in cygwin.
# git config --global difftool.winmerge.cmd "winmerge-diff.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\""
# git config --global mergetool.winmerge.trustExitCode false
# git difftool -t winmerge branch1..branch2
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
# Reference: http://winmerge.org/docs/manual/CommandLine.html
library=~/gittool/githelperfunctions.sh
#[ -f $library ] && . $library
. $library
echo Launching winmerge.exe - winmerge-diff.sh:
set_path_vars "$1" "$2" "$3" "$4"
"$winmergewinpath" /dl "LOCAL.$caption" /dr "TO_VERSION.$caption" "$localwinpath" "$remotewinpath"
#!/bin/sh
# Use winmerge as mergetool for git in cygwin.
# git config --global mergetool.winmerge.cmd "winmerge-merge.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\""
# git config --global mergetool.winmerge.trustExitCode false
# git mergetool -t diffmerge
# Reference: http://www.tldp.org/LDP/abs/abs-guide.pdf
# Reference: http://winmerge.org/docs/manual/CommandLine.html
library=~/gittool/githelperfunctions.sh
#[ -f $library ] && . $library
. $library
echo Launching winmerge.exe - winmerge-merge.sh:
set_path_vars "$1" "$2" "$3" "$4"
# -- use WinMergeU conflictFile
"$winmergewinpath" "$mergedwinpath"
@windviki
Copy link
Author

Create gittool directory in your home dir, and put all of these files in it (~/gittool).
Feel free to modify the githelperfunctions.sh to set your own paths of Beyond Compare and other tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment