Created
April 14, 2016 10:59
-
-
Save tsayen/f1c1c4d62d4fda77abf1586bd39f9b74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Usage: | |
# ./git-move.sh path/to/file/or/dir path/to/destination/repo | |
echo "creating patch for path ${1}" | |
git log --name-only --pretty="format:" --follow "${1}" \ | |
| sort -u | \ | |
xargs git log --pretty=email --patch-with-stat --reverse --full-index --binary -m --first-parent -- > "${2}/_patch_" \ | |
&& echo "moving to destination repo at ${2}" \ | |
&& cd "${2}" \ | |
&& echo "applying patch" \ | |
&& git am --committer-date-is-author-date < _patch_ \ | |
&& echo "OK" |
I liked the @dflock's version, but I wanted to keep the detailed history (not just merges), so I removed --first-parent
and added --no-merges
to the git-log invocation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, tsayen. I expanded on this a bit to meet my local needs -- https://github.com/wesgarland/git-relocate