Skip to content

Instantly share code, notes, and snippets.

@joeyates
Last active February 23, 2023 17:34
Show Gist options
  • Save joeyates/0d7ea137fedd1a5a3941 to your computer and use it in GitHub Desktop.
Save joeyates/0d7ea137fedd1a5a3941 to your computer and use it in GitHub Desktop.
Copy a commits from one Git repo to another
# Copy all modifications to a file from one repo to another
for c in `git --git-dir=../path/to/repo/.git log --reverse --pretty=tformat:"%H" -- path/to/file`; do
git --git-dir=../path/to/repo/.git format-patch --keep-subject -1 --stdout $c | git am --3way --keep;
done
# Copy a single commit from one repo to another
git --git-dir=../path/to/repo/.git format-patch --keep-subject -1 --stdout COMMIT | git am --3way --keep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment