3 # Implement the suggestion here:
4 # http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/
5 # Note that if the file was moved, you only get history since the move.
9 echo "USAGE: `basename ${0}` <repository> <file or directory>"
14 ( cd / ; /bin/pwd -P ) >/dev/null 2>&1
15 if (( $? == 0 )); then
19 thisdir=`cd ${reldir} && /bin/pwd ${pwd_P_arg}`
25 if [ -z ${repo} ]; then
29 if [ -z ${myfile} ]; then
36 echo " script directory: ${thisdir}"
37 echo " current directory: ${currentdir}"
39 patchdir=${currentdir}/${repo}patch
41 cd ${currentdir}/${repo}
43 git format-patch -o ${patchdir} $(git log ${reposrc}|grep ^commit|tail -1|awk '{print $2}')^..HEAD ${reposrc}
46 echo "Patch files have been created in ${patchdir}"
47 echo "cd <destination repository>"
48 echo "git am ${patchdir}/*.patch"