Git create a branch and submit to a remote branch

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/sinat_22797429/article/details/82429453

Create a local branch and submitted to the remote

  • 1. git branch -r command to see the situation the distal branch libraries (the other branches not list)
    Here Insert Picture Description
  • 2. Create a new branch (such as from the develop branch) from an existing branch, create a branch newneeds_0215
    Here Insert Picture Description
  • 3. We git branch -a look at the current branch, over the discovery has been switched
    Here Insert Picture Description
  • 4. We will try to git push to push local branch to the remote and found the following error:
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

Here Insert Picture Description
The problem is not the local branch and a remote branch warehouse associate, there are many remote branches, you do not know in the end want to push the branch up

  • 5. We enter git push --set-upstream origin feature /
    newneeds_0215 local branch pushed to the remote newneeds_0215 branch, and this time I'll git branch -r you can see the remote branch newneeds_0215

Guess you like

Origin blog.csdn.net/sinat_22797429/article/details/82429453