一个项目同时提交到 GitHub 和 Gitee 两个仓库

Gitee 新建仓库并关联克隆 GitHub 仓库

image-20210415193414023

修改 Git 的配置文件./git/config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
# github仓库地址
url = https://github.com/netxulei/hngk-git.git
# gitee仓库地址
url = https://gitee.com/netxulei/hngk-git.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master

git remote -v 可查看配置

1
2
3
4
$ git remote -v
origin https://github.com/netxulei/hngk-git.git (fetch)
origin https://github.com/netxulei/hngk-git.git (push)
origin https://gitee.com/netxulei/hngk-git.git (push)

提交命令

1
git add .
1
git commit -m "注释"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 6 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 229 bytes | 229.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/netxulei/hngk-git.git
46859bb..974d410 master -> master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 6 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 229 bytes | 229.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/netxulei/hngk-git.git
46859bb..974d410 master -> master