简体   繁体   中英

How to sync changes from some sub-folders of a Git repo to another Git repo preserving the commit history

I have two repos repo-A and repo-B with below folder structure

Repo-A
—— folder1
—— folder2
—— folder3

Repo-B
—— folder1 //same copy of the repo-A folder1
—— folder2 //same copy of the repo-A folder2

The plan is, I'm modularising the existing repo repo-A by extracting out one business flow to a new repo repo-B. Developers still using repo-A until repo-B becomes stable. Means, developers are still pushing changes to repo-A folder1 and folder2. I need to sync the changes on these folders to repo-B folders.

I read about filter-branch and post-receive hook. But I couldn't find a proper way to implement this. It'd be helpful if someone can point-out an optimal approach.

Finally I got the perfect solution I wanted. git filter-repo can be used to rewrite the commit history just for the subfolders we wanted. Later we can pull these changes to the new repo.

Examples, are here: https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#EXAMPLES

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM