3

I am improving my friend's LaTeX document at folder 1/2, while he is editing the folder 1/1.

The initial contents of the folders is the same.

How can you meld the two folders to one such that all files are melded?

3 Answers 3

9

You're wanting to find the differences in files in two folders and merge the changes?

If you're looking for a GUI utility you can use FileMerge which can be found at /Developer/Applications/Utilities/ if you have Apple's Developer Tools installed. It has some odd bugs - mostly to deal with handling file encoding.

If you're looking for something faster and nicer check out Changes.app - it's not cheap but has been worth the price of admission several times over for me.

If you want to do it via the command line you can use diff to find the differences and then manually merge the files together as it will list all the differences. (eg. diff ~/Desktop/a ~/Desktop/b)

2

Since the mac is running a version of unix, you can use all of the tried, tested and true commands from the established UNIX heritage.

UNIX Shell Comparison of Directories Tutorial

2

The following code is made by Git-community

#!/bin/sh
#
# Filemerge.app must not already be open before running
# this script, or opendiff below will return immediately,
# and the TMPDIRs deleted before it gets the chance to read
# them.

[ \$# -eq 7 ] && opendiff "\$2" "\$5"
EOF
chmod +x merge.sh
GIT_EXTERNAL_DIFF=./merge.sh git-diff 


if test $# = 0; then
   OLD=`git-write-tree`
elif test "$1" = --cached; then
   OLD=HEAD
   NEW=`git-write-tree`
   shift
fi
if test $# -gt 0; then
   OLD="$1"; shift
fi
test $# -gt 0 && test -z "$CACHED" && NEW="$1"

TMPDIR1=`mktemp -d`
git-archive --format=tar $OLD | (cd $TMPDIR1; tar xf -)
if test -z "$NEW"; then
   TMPDIR2=$(git rev-parse --show-cdup)
   test -z "$cdup" && TMPDIR2=.
else
   TMPDIR2=`mktemp -d`
   git-archive --format=tar $NEW | (cd $TMPDIR2; tar xf -)
fi

opendiff $TMPDIR1 $TMPDIR2 | cat
rm -rf $TMPDIR1
test ! -z "$NEW" && rm -rf $TMPDIR2

You can then run

opendiff folder1 folder2

to achieve what I want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .