1.首先在GitHub和gitee上分别创建两个仓库
1.1在GitHub上创建test仓库
![image-20210130163635551](https://img-blog.csdnimg.cn/img_convert/8470b928026bb55be5b8352aa34b89de.png)
1.2在Gitee上创建test仓库
![image-20210130163826187](https://img-blog.csdnimg.cn/img_convert/3387018dcff544c917f506f003a87424.png)
2.在本地中初始化创建一个git本地分支
git init
![image-20210130164049654](https://img-blog.csdnimg.cn/img_convert/e5ef12eee4d4ef59b45b53be0f032704.png)
3.从GitHub或者gitee上将test仓库拉取到本地(这里选择克隆GitHub的test仓库)
git pull https://github.com/LJF2402901363/test.git
![image-20210130165529254](https://img-blog.csdnimg.cn/img_convert/e5ef12eee4d4ef59b45b53be0f032704.png)
4.进入 .git目录下修改config文件
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = https://gitee.com/ljf2402901363/test.git url= https://github.com/LJF2402901363/test.git fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin merge = refs/heads/master
![image-20210130170114933](https://img-blog.csdnimg.cn/img_convert/db9b1cee0fa8977b997dee3eb5233e6c.png)
![image-20210131130631996](https://img-blog.csdnimg.cn/img_convert/db9b1cee0fa8977b997dee3eb5233e6c.png)
注意,这里的GitHub和gitee远程源仓库地址url都是以https开头,都是用的是HTTPS协议,在从本地推送到远程仓库时候需要输入用户名和密码。
![image-20210131132344939](https://img-blog.csdnimg.cn/img_convert/65a2031170bd553ed47b990ef8e20e29.png)
也可以使用GitHub和gitee中的ssh协议,在本地配置好github和gitee的ssh秘钥后可以免密从本地推送到远程仓库,参考教程: windows下git配置github和gitee SSH-Key密钥方便同时将本地分支推送到远程仓库
![image-20210613180128618](https://img-blog.csdnimg.cn/img_convert/a7cf4594318cec9a73f377f190a8be25.png)
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = git@github.com:LJF2402901363/test.git url= git@gitee.com:ljf2402901363/test.git fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin merge = refs/heads/master
5.在本地创建一个test.txt文件用于测试上传到GitHub和gitee
git status
git add test.txt
git commit -m "提交了测试文件"
git push -u origin master
![image-20210130170258970](https://img-blog.csdnimg.cn/img_convert/d6e53ea22f5bf7970b0a6682aaaae767.png)
![image-20210130170437800](https://img-blog.csdnimg.cn/img_convert/d2b6e4917aed5433235b0bec18d89966.png)
6.查看GitHub和gitee是否提交到远程仓库
在GitHub查看到已经有了推送的文件,这个需要我们合并才能展示在main这个默认主干上;
gitee上直接就推送到了master这个主干上,所以直接可以看到推送上来的test.txt文件,不需要经过合并。
![image-20210130170904385](https://img-blog.csdnimg.cn/img_convert/54fc336e48cf9927183be40ca8f9a5b6.png)