COMMIT_TO_PORT=(commit hash)
for f in `git show --pretty="format:" --name-only ${COMMIT_TO_PORT}`
do
PATH_UNDER_MASTER=$f
PATH_UNDER_BRANCHA=(make branchA path out of $f)
FILEID=(optional - extract file name or some other ID to preserve new-old files for reference if auto-generated conflicts are not clear)
git show "${COMMIT_TO_PORT}:{$PATH_UNDER_MASTER}" > "new_${FILEID}"
git show "${COMMIT_TO_PORT}~1:{$PATH_UNDER_MASTER}" > "old_${FILEID}"
git merge-file $PATH_UNDER_BRANCHA "old_${FILEID}" "new_${FILEID}"
# optional - open $PATH_UNDER_BRANCHA
unset FILEID PATH_UNDER_MASTER PATH_UNDER_BRANCHA
done
unset COMMIT_TO_PORT
可能相關:http://stackoverflow.com/questions/9772598/backport-changes-from-renamed-file –