将一个项目同时推送到gitee和github

154 阅读1分钟

通过修改配置文件的方式提交多个仓库

创建远程仓库的步骤都是一样的,gitee和github上分别建立仓库

前面的步骤

git init   初始化本地仓库---在目录中创建新的 Git 仓库。

git add .  

git commit -m '描述'

git remote add origin https://......

git push  origin "master"

创建完仓库或以后在根目录找到.git/config文件,对其进行修改(注意.git目录默认是隐藏的),可以command+. 让它显示

1、首先,进入到项目的 .git 文件夹,打开 config 文件

截屏2022-08-17 23.58.53.png

2、然后,找到 [remote “origin”] ,原本只有一份,复制一份remote到下面,修改 remote的名字(随意)和url(远程仓库地址)即可
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
     🌸🌸🌸🌸修改以下内容🌸🌸🌸🌸
[remote "gitee"]
	url = gitee远程仓库地址
	fetch = +refs/heads/*:refs/remotes/gitee/*
[remote "github"]
	url = github远程仓库地址
	fetch = +refs/heads/*:refs/remotes/github/*

3、分别推送
git push gitee master
git push github master