• Now all data be ready for publish, We had made our blog alive now. Haha.



  • These days CCP GFW blocked all the IPs from US and when I switch my IP in google Cloud, the disk data cannot be restore again. I have to restart my blog totally, Now the website is still building…



How do I check out a remote Git branch?- Stack Overflow

Python PingBook 2 months ago (10-26) 18 0

Question

Somebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r.

Now I’m trying to check out the remote test branch.

I’ve tried:

git checkout test which does nothing
git checkout origin/test gives * (no branch). Which is confusing. How can I be on “no branch”?

How do I check out a remote Git branch?

Answer

Update

Jakub’s answer actually improves on this. With Git versions ≥ 1.6.6, with only one remote, you can just do:

git fetch
git checkout test

As user masukomi points out in a comment, git checkout test will NOT work in modern git if you have multiple remotes. In this case use

git checkout -b test /test

or the shorthand

git checkout -t /test

Old Answer

Before you can start working locally on a remote branch, you need to fetch it as called out in answers below.

To fetch a branch, you simply need to:

git fetch origin

This will fetch all of the remote branches for you. You can see the branches available for checkout with:

git branch -v -a

With the remote branches in hand, you now need to check out the branch you are interested in, giving you a local working copy:

git checkout -b test origin/test




Copyright from PingBook Blog, If not specified, they are original. This site uses BY-NC-SAProtocol authenticated.
For reprinting, please indicate the link of the original text:How do I check out a remote Git branch?- Stack Overflow
LIKE (0)
[1725641479@qq.com]
SHARE (0)
PingBook
Author:
We create, We sharing! Tag every value data your sharing
Submit comments
Cancel comments
emoji picture bold strikethrough center italic check in

Hi,you need to provide your name and email adress!

  • Name (Required)
  • Email (Required)
  • Website