Git创建分支并提交到远程分支

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_22797429/article/details/82429453

创建本地分支并提交到远程

  • 1. git branch -r 命令查看远端库的分支情况(其他分支就不列出来了)
    在这里插入图片描述
  • 2.从已有的分支创建新的分支(如从develop分支),创建一个newneeds_0215分支
    在这里插入图片描述
  • 3.我们git branch -a查看一下当前分支,发现已经切换过来了
    在这里插入图片描述
  • 4.我们通过git push试图将本地分支推到远程,发现出现以下报错:
fatal: The current branch feature/newneeds_0215 has no upstream branch.
To push the current branch and set the remote as upstream, use

   git push --set-upstream origin feature/newneeds_0215

在这里插入图片描述
问题的原因是没有将本地的分支与远程仓库的分支进行关联,远程有许多分支,不知道你到底想推到那个分支上去

  • 5.我们输入git push --set-upstream origin feature/newneeds_0215
    本地分支推到远程newneeds_0215分支上了,这时候我再git branch -r就可以看见远程newneeds_0215分支了

猜你喜欢

转载自blog.csdn.net/sinat_22797429/article/details/82429453
今日推荐