git 切换remote

新增 remote

命令行操作

git remote add gitlab git://***/***.git

添加成功后,查看本地remotes

git remote -v

gitlab  http://domain.com/project.git (fetch)

gitlab  http://domain.com/project.git (push)

origin  https://domain.com/project.git (fetch)

origin  https://domain.com/project.git (push)

通过SourceTree操作



2、push分支到指定的remote

git push [remote-name] [branch-name],如:

git push origin master

通过SourceTree操作





3、修改原有分支的remote-name

原来已经拉取的分支,如果执行git pull / git push,仍然会从 origin上 pull / push。

可在项目根目录 通过 vim .git/config 查看各分支的 remote-name情况。

可通过以下命令修改remote-name:

git branch branch_name --set-upstream-to your_new_remote/branch_name

示例:

git branch develop --set-upstream-to gitlab/develop

注意:需要新的remote上存在相应的分支,才能修改,否则报错:error: the requested upstream branch 'gitlab/branch_name' does not exist。可以通过以下两种方式解决该问题:

a. 在gitlab界面上基于master创建一个相应分支

b. 在本地push分支过去


4、查看分支配置

在项目根目录执行

vim .git/config

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值