git push 报错解决 -- git 关联本地分支和远程分支

git 关联本地分支和远程分支

报错信息

git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

git push origion
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origion master

添加远程分支

  • git remote add 地址 远程仓库别名
//加一个远程仓库并且命名为github
git remote add xxx.xxx.xx(远程仓库地址) github

关联

  • git branch --set-upstream-to=origin/remote_branch your_branch
  • 说明
    • git branch --set-upstream-to=远程仓库别名/远程分支名 本地分支名
  • 实例
//把本地主分支关联到远程仓库的主分支
git branch --set-upstream-to=github/master master

//把本地主分支关联到远程仓库的b2分支
git branch --set-upstream-to=github/b2 master

//把本地b2分支关联到远程仓库的rb2分支
git branch --set-upstream-to=github/rb2 b2
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值