修改.git文件夹中的config文件
原本:
[remote "origin"]
url = https://github.com/hexesdesu/CPlusPlusPlusPlusLearn.git
fetch = +refs/heads/*:refs/remotes/github/*
[branch "main"]
remote = github
merge = refs/heads/main
内部的gitlab上的master分支是收到保护的,所以新建了一个dev-hexin分支
并且在github上把默认分支的名称也改成了dev-hexin
修改后的config文件:
[remote "github"]
url = https://github.com/hexesdesu/CPlusPlusPlusPlusLearn.git
fetch = +refs/heads/*:refs/remotes/github/*
[remote "gitlab"]
url = http://git.dmsd.tech/training-p2p/net.git
fetch = +refs/heads/*:refs/remotes/gitlab/*
[branch "dev-hexin"]
remote = github
merge = refs/heads/dev-hexin
修改后,提交的时候可以选择是提交到远程的github还是gitlab,因为在家访问不到公司内网,如果一次性提交两个的话gitlab会报错
如果两个远程仓库都可以访问到的话可以这样配置:
[remote "git"]
url = https://github.com/hexesdesu/CPlusPlusPlusPlusLearn.git
url = http://git.dmsd.tech/training-p2p/net.git
fetch = +refs/heads/*:refs/remotes/github/*
[branch "dev-hexin"]
remote = git
merge = refs/heads/dev-hexin
更省事