参考博客 如何将 Github 上的仓库导入 CODING - 简书 (jianshu.com)
1、在coding上新建一个同名项目
注意:在初始化代码仓库不选择生成 README.md 文件和 .gitignore 文件。
2、将git上的项目clone到本地
本地执行克隆命令,并带上参数 --bare
git clone https://github.com/lanren312/monkey.git --bare
这里执行命令有个报错
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
大概意思就是不能使用账号密码的方式了,要是用token
创建方法:在git控制台点击右侧头像,选择Settings---Developer settings,按下图的操作,可以自定义token的有效期,选项我都选了,记好页面的token哟
这里还有个操作,修改已有项目的url,我这里是在项目的原文件夹下操作的。
git remote set-url origin https://你的令牌@github.com/用户名/项目名字.git
操作完了可以去项目的 .git文件夹下的查看config文件(url = https://你的令牌@github.com/用户名/项目名字.git),这个时候再去clone就不会有问题了
git clone https://你的令牌@github.com/lanren312/monkey.git --bare
3、进入到刚clone的目录下推送所有的分支和对象,向coding推送时,需要添加参数 --all
git push https://e.coding.net/monkey.git --all
用sourcetree将项目clone到本地,再看看history,你就会发现历史提交记录也过来了