meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| git:split_merge_repos [2017/02/20 13:30] – niziak | git:split_merge_repos [2024/01/17 11:48] (current) – niziak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Split or merge repos ====== | ||
| + | |||
| ====== Merge repos into one ====== | ====== Merge repos into one ====== | ||
| Line 19: | Line 21: | ||
| Then modify file location of repo BBB to be in desired path and merge it into repo LLL. | Then modify file location of repo BBB to be in desired path and merge it into repo LLL. | ||
| <code bash> | <code bash> | ||
| + | |||
| + | ######### WAY 2 | ||
| + | # Clone RRR repo temporary to change all file paths to new repo. | ||
| + | cd tmp | ||
| + | git clone http:// | ||
| + | git checkout main | ||
| + | # now move files from remote repo RRR into correct path: | ||
| + | mkdir app_RRR | ||
| + | git checkout -b branch_change_file_location | ||
| + | git mv -k * app_RRR/src | ||
| + | git mv src app_RRR/src | ||
| + | git mv .gitignore .gitlab-ci.yml .gitmodules app_RRR/src | ||
| + | |||
| + | git commit -m " | ||
| + | |||
| + | # optionally reword all commits: | ||
| + | git rebase --root -x 'git commit --amend' | ||
| + | |||
| + | cd LLL_repo | ||
| + | git remote add RRR / | ||
| + | git fetch RRR | ||
| + | git merge RRR/ | ||
| + | ######### WAY 2 END | ||
| + | |||
| + | ######### WAY 1 | ||
| git remote add RRR http:// | git remote add RRR http:// | ||
| git fetch RRR | git fetch RRR | ||
| - | git checkout -b branch_change_file_location RRR/master | + | git checkout -b branch_change_file_location RRR/main |
| # now move files from remote repo RRR into correct path: | # now move files from remote repo RRR into correct path: | ||
| mkdir app_RRR | mkdir app_RRR | ||
| git mv src app_RRR/src | git mv src app_RRR/src | ||
| - | git commit -m " | + | git commit -m " |
| # switch to LLL repo | # switch to LLL repo | ||
| git checkout master | git checkout master | ||
| # merge previously created branch " | # merge previously created branch " | ||
| - | git merge branch_change_file_location | + | git merge branch_change_file_location |
| git commit | git commit | ||
| + | ######### WAY 1 END | ||
| # cleanup | # cleanup | ||
| Line 38: | Line 66: | ||
| git branch -d branch_change_file_location | git branch -d branch_change_file_location | ||
| - | # optionally: | + | # optionally |
| + | # rebase can be problematic. Conflict will be on commonly used paths (readme, Makefile, src, etc) | ||
| + | # between LLL and RRR repo | ||
| git rebase | git rebase | ||
| # push merged master | # push merged master | ||
| Line 79: | Line 109: | ||
| </ | </ | ||
| + | |||
| + | ====== Split one file from repo ====== | ||
| + | |||
| + | <code bash> | ||
| + | # reduce repo to one folder | ||
| + | git filter-branch --prune-empty --subdirectory-filter etc -- --all | ||
| + | |||
| + | # reduce repo to some given file/files | ||
| + | git filter-branch -f --prune-empty --index-filter 'git rm --cached --ignore-unmatch $(git ls-files | grep -v " | ||
| + | |||
| + | # clean | ||
| + | git reflog expire --expire=now --all && git gc --prune=now --aggressive | ||
| + | </ | ||
| + | |||
| + | |||