Move files from one git repo to another, preserving history
Project description
git-repo-move
Move files from one git repo to another, preserving history!
Under the hood, this utility uses git filter-branch, but the API is much more user friendly.
How-To
Install
pip install git-repo-move
Build Locally
poetry build
Run It
If you've already installed in via pip, it's really easy to use.
The program is called git-repo-move.
You can also checkout the source and build locally by running:
poetry install --no-dev
Select Files and Directories
Select what files you want to keep by specifying:
--file path/to/file.txt --file path/to/another_file.txt
and what directories you want to keep by specifying:
--directory path/to/subfolder --directory path/to_another subfolder
Select the Final Directory for the Files
Optionally, specify the final directory for the files
--final_directory newpath/to/thefiles
Select Directory Structure
You can either flatten all files or keep the original directory structure
--directory-structure <FLAT|ORIGINAL>
For example:
--file path/to/file.txt --final-directory newpath/to/thefiles --directory-structure FLAT
file.txt will end up at newpath/to/thefiles/flat.txt
--file path/to/file.txt --final-directory newpath/to/thefiles --directory-structure ORIGINAL
file.txt will end up at newpath/to/thefiles/path/to/file.txt
Specify the Git Remote URL of the Destination Repo
You can run git remote -v to get a list of remote URLs.
--git-remote-url git@github.com:AlanRosenthal/git-repo-move.git
Specify the Git Branch Name
Remember this branch will used on both repos.
--git-branch move_files
Save Shell Script
This utility generates a shell script.
By default, the script will be saved in the root of the repo with the name git-repo-move.sh.
You can change the default name by specifying
--shell-script-name best-script-ever.sh
It is recommended to include the generated shell script on your PR.
Optionally, don't save a shell script by specifying the --dont-save-shell-script flag.
Try It Out
This utility uses git-filter-branch which is relatively slow, especially for large repos.
It usually takes a few attempts to specify the correct files and directories.
By specifying the --try-keep flag, git-repo-move will move the specified files into a folder.
Inspect that folder to ensure everything is correct.
Execute
By specifying the --execute flag, the generated script will be executed.
Example
We're using click for the example.
We want to save src/click/formatting.py and src/click/parser.py and have them end up in the folder alan/click.
Running the command:
git-repo-move --file click/formatting.py --file src/click/formatting.py --file click/parser.py --file src/click/parser.py --final_directory alan/click --directory-structure flat --git-remote-url git@github.com:AlanRosenthal/git-repo-move.git --git-branch move_files_example --execute
Note: We're including click/formatting.py & src/click/formatting.py and click/parser.py & src/click/parser.py.
Files were moved from click to src/click.
git-blame knows how to capture files history across moves, but git-filter-branch does not.
As you can see, the move_files_example branch has contains two files, formatting.py and parser.py.
Both files contain the history from their original repo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git-repo-move-1.0.1.tar.gz.
File metadata
- Download URL: git-repo-move-1.0.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64b4451165d02aa2ae97f82dcdb23fa73574a309e14ba808965060ec27597876
|
|
| MD5 |
765fd220949508c2f47a357e4f717d71
|
|
| BLAKE2b-256 |
b82b99d3b07887bfdf0f174078b5201f9423645a9311c9fe280be72af4b2a4ba
|
File details
Details for the file git_repo_move-1.0.1-py3-none-any.whl.
File metadata
- Download URL: git_repo_move-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8890154d1ff63c458ede0d75dcb93406c0d8d64c41ceae6f37c182ac727dcd32
|
|
| MD5 |
445369e9723dcb13ce405ecd251e2267
|
|
| BLAKE2b-256 |
19743b01eb43a2e9c105bb7c26d93cc9642234a85d811744d932cc91f46940b2
|