git 本地项目和远程仓库关联

1、本地创建git仓库,命令:git init

2、本地仓库和远程仓库关联,假设远程仓库在github上,地址为:https://github.com/xxx/xxx,执行命令:

     git remote add origin https://github.com/xxx/xxx

3、本地项目push到远程,执行命令:git push origin xxx,具体参考如下情况:

     推送本地分支local_branch到远程分支 remote_branch并建立关联关系,分为如下3种情况:

      (1)远程已有remote_branch分支且已经关联本地分支local_branch且本地已经切换到local_branch,执行命令:

          git push

      (2)远程已有remote_branch分支但未关联本地分支local_branch且本地已经切换到local_branch,执行命令:

          git push -u origin/remote_branch

      (3)远程没有有remote_branch分支并,本地已经切换到local_branch,执行命令:

          git push origin local_branch:remote_branch

 4、若本地push到远程报错,需要看是否远程有更新未pull到本地,执行git命令:

          git pull origin 远程分支名(如:master)

 5、若在项目新建阶段,pull 报错,可以执行命令:

          git pull origin master --allow-unrelated-history

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值