Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakub-g/git-move-folder-between-repos-keep-history
:heavy_dollar_sign: :heavy_plus_sign: :heavy_minus_sign: :white_check_mark: Move folder from one git repo to another, with full history.
https://github.com/jakub-g/git-move-folder-between-repos-keep-history
Last synced: about 1 month ago
JSON representation
:heavy_dollar_sign: :heavy_plus_sign: :heavy_minus_sign: :white_check_mark: Move folder from one git repo to another, with full history.
- Host: GitHub
- URL: https://github.com/jakub-g/git-move-folder-between-repos-keep-history
- Owner: jakub-g
- License: mit
- Created: 2017-11-02T17:42:05.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-04T16:28:12.000Z (over 1 year ago)
- Last Synced: 2024-04-18T12:54:23.176Z (8 months ago)
- Language: Shell
- Homepage:
- Size: 9.77 KB
- Stars: 7
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# git-move-folder
Move folder from one git repo to another, with full history.
*Note: git sha1-s are not preserved after migration (it's not possible in general case; before merging code from one repo to another, the script recreates git commits, filtering out the changes done outside of the folder being moved)
# Usage
Check the `.sh` file. You don't need advanced bash skills. Basically you should:
1. Copy this file to a handy place (outside of the repos you modify)
2. Modify the variables the top of the file
3. Make sure the repos modified are in clean state (`git status`)
4. Run the `.sh` file and let it do the magicNote that the script will go over each commit in git history one by one, so it may take a while to complete on huge repos (progress is logged though on each commit).
It is however optimized to skip the commits that do not touch the folder moved, so if the folder is just a small part of a huge repo, it should be relatively fast.
If something goes wrong, you can comment out (with `#`, or just delete the line) the `importFolder...` method call at the end of the file, uncomment the `undoImport...` method call, run the script to undo, then modify the params or the code itself, and rerun.
Even if I put a lot of safety belts (`verifyPreconditions`) and an undo functionality , for extra safety, DO NOT RUN THIS SCRIPT ON YOUR ORIGINAL REPOS. Make full copies of the repos you want to play with before running the script - better safe than sorry. The script uses some dangerous git methods that rewrite repo history.
You've been warned :) Now back up your stuff and enjoy the script.
If you liked it, [please upvote my StackOverflow answer](https://stackoverflow.com/a/47081782/245966).