:
A, , . , ( 3). 4 . , , 1. 1 A. , B , ( 5/6). .
1. git clone <git repository A url>
2. cd <git repository A directory>
3. git remote rm origin
4. git filter-branch --subdirectory-filter <directory 1> -- --all
5. mkdir <directory 1>
6. mv * <directory 1>
7. git add .
8. git commit
:
B, . 3 A B. ( , ) B. . . , . , , , , A. Commit .
1. git clone <git repository B url>
2. cd <git repository B directory>
3. git remote add repo-A-branch <git repository A directory>
4. git pull repo-A-branch master
5. git remote rm repo-A-branch
A B
.
git log --all --oneline --graph --decorate --abbrev-commit
copy (cherry-pick) A repo B repo.
git cherry-pick sha-of-commit-one
git cherry-pick sha-of-commit-two
git cherry-pick sha-of-commit-three
.
git log
( ) .
git push origin master
oldrepo A.
git remote remove oldrepo A
, A B Repo
Find all the commits by author and save their hash in a file:
git log --author=<author> --format=%H > /tmp/commit-by-author
Create a new branch that does not contain this particular author commit. To do this, you can create a new empty branch:
git checkout --orphan commits-by-author
Cherry - select all commits of this author (from A to B Repo):
tac /tmp/commit-by-x | while read sha; do git cherry-pick ${sha}; done
source
share