用户登录
用户注册

分享至

同步代码至 Github 和 Gitee

  • 作者: 欧罗提拉稀
  • 来源: 51数据库
  • 2021-08-20

目录

  • 同步代码至 Github 和 Gitee
    • 方式一:导入仓库
    • 方式二:同步更新
      • 一、同步
      • 二、查看
      • 三、更新
      • 四、纠错


同步代码至 Github 和 Gitee

方式一:导入仓库

登陆 Gitee 账号,点击右上角的 + 号,点击「从 GitHub 导入仓库」,在跳转的页面中授权 Gitee 访问。

方式二:同步更新

一、同步

  • 删除已关联的名为 origin 的远程库
    git remote rm origin
  • 关联 GitHub 的远程库
    git remote add github https://github.com/?.git
  • 关联 Gitee 的远程库
    git remote add gitee https://gitee.com/?.git
  • 修改.git文件夹内的config文件
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "github"]
	url = git@github.com:chloneda/demo.git
	fetch = +refs/heads/*:refs/remotes/github/*
[remote "gitee"]
	url = git@gitee.com:chloneda/demo.git
	fetch = +refs/heads/*:refs/remotes/gitee/*
  • 上传代码
    git add .
    git commit -m “message”
    git push github branch
    git push gitee branch

二、查看

  • 查看远程库信息
    git remote -v

    可以看到两个远程库说明配置生效

三、更新

  • 更新代码
    git pull github
    git pull gitee

四、纠错

  • fatal:refusing to merge unrelated histories(拒绝合并无关的历史)
    • 将远程仓库和本地仓库关联起来
      git branch --set-upstream-to=origin/remote_branch your_branch
      其中,origin/remote_branch是你本地分支对应的远程分支,your_branch是你当前的本地分支。
    • 整合远程仓库和本地仓库
      git pull --allow-unrelated-histories
      忽略版本不同造成的影响。

参考自:https://gitee.com/help/articles/4284#article-header0
原文链接:https://qwert.blog.csdn.net/article/details/107888017

软件
前端设计
程序设计
Java相关