Git realizes the merging of all records in different warehouses, merging code warehouses and submission records

Git implements merging of all records in different warehouses

Git's submission record is the main wealth of programmers. Whether it is to look at the reasons for predecessors' modifications or to blame others, it is essential. If you are merging some code warehouses, you want to keep all the commitrecords and at the same time When migrating the code, you can refer to the following logical processing
[Note]: Be sure to make a backup! ! !

1. Create and switch to a new branch

Create and switch new branches on the repository where records need to be merged, such as:merge_git_branch

2. Add another warehouse as a remote warehouse

git remote add <remote_name> <remote_repository_url>

3. Pull the commit records from the remote warehouse to the local branch

git fetch <remote_name>

4. Merge the target warehouse code into the specified folder of the current warehouse

Can be used git subtree/ git filter-branchimplemented here usinggit subtree

git subtree add --prefix=<目标文件夹名称> <remote_name>/<remote_url>

Case:

-- 在父目录下创建一个 mergeGitRecordDir 目录,拉取远程仓库 remote_name 的 master 分支代码到这个目录
git subtree add --prefix=mergeGitRecordDir  remote_name/master

5. Push to the remote branch of the warehouse

git push origin merge_git_branch

Guess you like

Origin blog.csdn.net/qq_40542534/article/details/135294691