带着历史提交记录迁移git仓库
2023-09-14 09:00:17 时间
1. git push --mirror
--mirror模式会把本地的分支都克隆
// 先用--bare克隆裸仓库 git clone git@gitee.com:zhangamie/testApp.git --bare // 进入testApp.git,这样就可以把所有分支都克隆到新仓库了 git push --mirror git@gitee.com:zhangamie/testApp2.git
或
// 普通模式克隆仓库 git clone git@gitee.com:zhangamie/testApp.git // push所有本地已存在的分支(不管是否有对应的远程分支) git push --mirror git@gitee.com:zhangamie/testApp2.git
2. 加远程源
git remote add origin2 git@gitee.com:zhangamie/testApp2.git
git push origin2
git checkout dev
git push origin2
...
这种方式的缺点是只能一次push一个分支,如果要克隆所有分支,需要checkout到各个分支然后push
3. git subtree
推荐阅读:git subtree操作
上面2种都是整个仓库的迁移,而git subtree可以把某个子目录拆出去
例如想把仓库的目录src/apps/testApp拆出去一个仓库,并且带上这个目录的所有提交历史记录
首先我们得创建一个空的仓库(记得别带任何初始化文件,例如README.md)
例如:git@github.com:xxxx/testApp.git master
然后到主仓库执行这段git命令,就可以到testApp看到代码啦
git subtree push --prefix=src/apps/testApp git@github.com:xxxx/testApp.git master
相关文章
- Centos6.8搭建Git服务(git版本可选)
- C# EntityFramework Code First 迁移
- 【ASM学习】普通数据库向ASM实例的迁移(二)
- [git]Git与Repo入门
- [git/svn]Git和SVN差异
- Git创建分支/GIT提交分支
- [Git] A better git process
- [Practical Git] Remove unnecessary git tracking with .gitignore files
- EXP/IMP迁移数据 导入导出全过程
- 迁移数据文件到ASM【转】
- Git远程04:git fetch & git push & git pull
- studio--如何将Eclipse中的项目迁移到Android Studio 中
- [Git] Recover Local Changes from `git reset --hard` with `git reflog`
- [Git] Use and Compare the Different git Reset Options: --hard, --soft, and --mixed
- [Practical Git] Compare file changes with git diff
- [Practical Git] Format commit history with git log arguments
- PHP扩展迁移为兼容PHP7记录
- paddlepaddle 14 迁移学习-图像分类实战一 基于paddle2(paddle.hub)实现动态图的迁移学习
- DBConvert Studio - 数据库迁移和同步 - Crack
- gitlab 迁移 gitlab 升级 gitlab docker 部署,你要的 这里都有
- 数据不够怎么训练深度学习模型?不妨试试迁移学习 ——重用神经网络的结构2
- Git 报错fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem bounda
- Git的fatal: Not a git repository (or any parent up to mount point /home)
- 阿里云RDS数据库基于DTS进行数据迁移(二十四)
- [Git & GitHub] git 常用命令
- [Git & GitHub] Windows安装git和环境变量配置