git提交代码到多个远程仓库(github.com、git.oschina.net)

概述

需求如下:我在git.oschina.net提交了项目,现在想转到github。最终想达到的效果是:每次提交代码,github跟git.oschina.net同时更新。

我的代码仓库地址如下:
github
git.oschina.net

背景介绍

目前我的git config文件内容如下:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    url = https://git.oschina.net/0604hx/nerve-tools.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

按照自己搜索出来的方法,执行以下命令时出错了(fatal: remote origin already exists.):

git remote add origin https://github.com/0604hx/nerve-tools.git

解决

后来发现,只需要在原来的config中加入新的地址即可,修改后的配置如下
这里写图片描述
此时执行代码提交:

git push -u origin master

会让你输入两个仓库的登录帐密,然后就ok了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

集成显卡

码字不易,需要您的鼓励😄

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值