git同步更新GitHub和码云

php学习交流吧

共 1175字,需浏览 3分钟

 · 2021-04-25

首先github和码云上的仓库都要建好。然后将其中一个仓库clone到本地

git clone XXXXX


修改.git里面的配置文件config

[core]    repositoryformatversion = 0    filemode = false    bare = false    logallrefupdates = true    symlinks = false    ignorecase = true[remote "github"]    url = https://github.com/****/note    fetch = +refs/heads/*:refs/remotes/origin/*# 添加码云的url[remote "gitee"]    url = https://gitee.com/****/note    fetch = +refs/heads/*:refs/remotes/origin/*[branch "master"]    remote = origin    merge = refs/heads/master


提交代码时

git add .git commit -m "update"#提交到githubgit push github master#提交到码云git push gitee master


拉取更新时

#从github拉取更新git pull github#从码云拉取更新git pull gitee如果很少拉取更新或者嫌上面这个麻烦可以


[core]    repositoryformatversion = 0    filemode = false    bare = false    logallrefupdates = true    symlinks = false    ignorecase = true[remote "origin"]    url = https://github.com/****/note    # 在这里添加码云的urlurl = https://gitee.com/****/note    fetch = +refs/heads/*:refs/remotes/origin/*[branch "master"]    remote = origin    merge = refs/heads/master


这样提交时只用git push origin master,不用分别提交。

浏览 38
点赞
评论
收藏
分享

手机扫一扫分享

举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

举报