将github仓库同步到gitee
参考 ➠ 一次git同时提交到Github和Gitee
在本地使用git提交时,会配置SSH密钥。这个密钥与github是一致的,否则也不会提交成功。那么将这个密钥也复制粘贴到Gitee的SSH公钥配置处,这样可以保证本地使用git可以提交到Gitee。
其次在项目内的.git隐藏目录内,找到config文件,进行修改。起初是
[core]repositoryformatversion = 0filemode = truebare = falselogallrefupdates = trueignorecase = trueprecomposeunicode = true[remote "origin"]url = git@github.com:isgangzi/weigBlog.gitfetch = +refs/heads/*:refs/remotes/origin/*[branch "main"]remote = originmerge = refs/heads/main
修改后
[core]repositoryformatversion = 0filemode = truebare = falselogallrefupdates = trueignorecase = trueprecomposeunicode = true[remote "origin"]url = git@github.com:isgangzi/weigBlog.giturl = git@gitee.com:isgangzi/weigBlog.gitfetch = +refs/heads/*:refs/remotes/origin/*[branch "main"]remote = originmerge = refs/heads/main
在原来的github仓库地址下面再添加一个url配置,指向gitee的地址。保存
通过git config --list可查看刚刚是否修改正确
此时再修改本地代码,不论「通过IDEA的git键提交」还是「通过命令行」都会同时提交到github和gitee。
不觉得麻烦,使用手动同步也可以 登陆Gitee ➠ 关联Github账号 ➠ 右上角+号处同步Github项目到Gitee中
