git仓库迁移

1.克隆项目

git clone https://gitlab.365pp.com/wechat/project_old.git

2.查看本地添加了哪些远程地址

git remote -v
// 输出结果
origin https://github.com/wechat/project_old.git (fetch)
origin https://github.com/wechat/project_old.git (push)

3.删除添加的远程仓库地址

git remote remove origin

4.添加远程仓库关联

git remote add origin https://gitlab.365pp.com/wechat/project_new.git

5.查看本地添加了哪些远程地址

git remote -v
// 输出结果 添加成功
origin https://github.com/wechat/project_new.git (fetch)
origin https://github.com/wechat/project_new.git (push)

6.将本地仓库推送到远程仓库

git push -u origin master

注意:
如果git push 时候报错
! [remote rejected] master -> master (pre-receive hook declined)

原因:权限问题,Develop角色默认下没有远程访问master的权限

解决方案:
在项目的【Setting】中的【Protected branches】可以设置哪些分支是被保护的,默认情况下【master】分支是处于被保护状态下的,develop角色的人是无法提交到master分支的,在下面的【Developers can push】打上钩就可以了。

另外使用git push --mirror可以提交本地所有分支

git push --mirror https://github.com/wechat/project_new.git 

git push --mirror和git push有什么区别?

git push <origin> <master> 提交某个分支.
git push --mirror <remote-git-url> 提交所有分支.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值