Last active
July 18, 2022 03:39
-
-
Save davidonlaptop/36234fd9fa7f1a0f6b2cd5296216f280 to your computer and use it in GitHub Desktop.
Revisions
-
davidonlaptop revised this gist
Jul 18, 2022 . 1 changed file with 17 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,16 +18,24 @@ cd tmprepo1/ git filter-repo --path subfolder --tag-rename '':'subfolder-prefix-' # or git filter-repo --path subfolder --to-subdirectory-filter move-to-this-folder --tag-rename '':'subfolder-prefix-' ``` ### 4. Import the branch with rewritten history into a new branch in destination repository ``` cd tmprepo2 git remote add tmpremote $HOME/workspace/tmprepo1 git fetch tmpremote git checkout -b imported-branch tmpremote/main ``` ### 5. Rebase on main branch, cleanup temporary remote, and push imported branch to destination remote ``` git rebase main git remote remove tmpremote git push -u origin imported-branch ``` ### Links - https://github.com/newren/git-filter-repo#simple-example-with-comparisons - https://gist.github.com/davidonlaptop/68bcabb20e384207a58a885fddd086e5 -
davidonlaptop created this gist
Jul 18, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ ### 1. Install git-filter-repo ``` brew install git-filter-repo # or just download the single python file ``` ### 2. Clone fresh copy of both of your repo (in case you mess up) ``` git clone [email protected]:YOUR_ORGANIZATION/repo1.git tmprepo1 git clone [email protected]:YOUR_ORGANIZATION/repo2.git tmprepo2 ``` ### 3. Rewrite the history on the local copy of the first repo to only include the subfolder you want The single quotes are unnecessary, but make it clearer to a human that we are replacing the empty string as a prefix with my-module- ``` cd tmprepo1/ git filter-repo --path subfolder --tag-rename '':'subfolder-prefix-' # or git filter-repo --path subfolder --to-subdirectory-filter move-to-this-folder --tag-rename '':'subfolder-prefix-' cd .. git clone [email protected]:Berkindale/berkindale-web.git berkindale-web-subtree9 cd berkindale-web-subtree9 git remote add tmpremote $HOME/workspace/berkindale/berkindale-experiments-subtree9 git fetch tmpremote git checkout -b dlauzon/import-quotemedia-api-user tmpremote/main git rebase main git remote remove tmpremote git push -u origin dlauzon/quotemedia-api