Last active
May 6, 2021 15:06
-
-
Save giggio/6d898821a1f5b10a9142bb60c04fc3af to your computer and use it in GitHub Desktop.
Copy a commit from any repo to any other repo
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
# copy a single commit | |
git --no-pager --git-dir=<original_dir>/.git format-patch -k -1 --no-color --stdout <commit_sha> | git am -3 -k --ignore-whitespace | |
# copy a whole repo (branch main, change accordingly): | |
GIT_DIR=<original_dir>/.git # change to correct dir | |
for ID in `git --no-pager --git-dir=$GIT_DIR rev-list main | tac`; do | |
git --no-pager --git-dir=$GIT_DIR format-patch -k -1 --no-color --stdout $ID | git am -3 -k --ignore-whitespace | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment