Skip to content

Instantly share code, notes, and snippets.

@nowox
Created March 24, 2015 13:20
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 nowox/0ee91465d94a52f6cd3e to your computer and use it in GitHub Desktop.
Save nowox/0ee91465d94a52f6cd3e to your computer and use it in GitHub Desktop.
Improve workflow with Git and BeyondCompare
#!/usr/bin/bash
#File: git-diffbeyond
#Author: Yves Chevallier <nowox@x0x.ch>
#Date: 2015-03-24 Tue 02:16 PM
head="HEAD~1"
# Create temporary folder
OUT="$(mktemp -d)"
# Copy current files into this folder
cp -v --parents `git ls-files` $OUT
# Copy old files from HEAD
for file in $( git diff --name-only ); do git show $head:$file > $file.old && cp $file.old $OUT/$file; done
# Create BCompare filter
ignored="$(git check-ignore ** | perl -ne 'chomp; next unless -f; s/([()])/\\$1/g; print "-$_;";')"
untracked="$(git ls-files --others --exclude-standard | perl -ne 'chomp; next unless -f; s/([()])/\\$1/g; print "-$_;";')"
git="-.git/;"
# Execute BCompare
left="$( cygpath -wa . )"
right="$( cygpath -wa $OUT )"
/cygdrive/c/BeyondCompare3/Bcomp /filters=$git$ignored$untracked $left $right
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment