git switches to remote branch

Source: Internet
Author: User

Transferred from: http://www.barretlee.com/blog/2014/04/30/switch-branch-in-git/

Remote repository git clone down and when you execute GIT branch, you'll only see

* master

Do not see other branches, even if there are other branches on the remote repository, use the

git branch -va

You can view the local + remote branches list

master              0840594 merge master and 1.0.0remotes/origin/1.0.0 743012a ‘update‘remotes/origin/2.0.0 2787838 udpateremotes/origin/HEAD -> origin/masterremotes/origin/master 0840594 merge master and 1.0.0

If you want to switch to origin/2.0.0 's branch, we can

git branch remotes/origin/2.0.0

But the result is not satisfactory:

* (detached from origin/2.0.0)master

Git branch will see the above information, and here's one more step:

2.0.0

-B means base, with the current branch as base, and a new branch named 2.0.0, which of course can also use other names. At this point, you can see the following GIT branch:

$ git br  master* 2.0.0

It's OK.

The most straightforward approach is to:

git checkout -t origin/2.0.0

Ability to create a new local branch and extract the remote branch directly.

git switches to remote branch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.