How do I check out a remote Git branch?

后端 未结 30 1869
灰色年华
灰色年华 2020-11-22 00:12

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

<
相关标签:
30条回答
  • 2020-11-22 00:34

    git checkout -b "Branch_name" [ B means Create local branch]

    git branch --all

    git checkout -b "Your Branch name"

    git branch

    successfully checkout from the master branch to dev branch

    0 讨论(0)
  • 2020-11-22 00:34

    Please follow the command to create an empty folder. Enter that and use this command:

    saifurs-Mini:YO-iOS saifurrahman$ git clone your_project_url
    Cloning into 'iPhoneV1'...
    remote: Counting objects: 34230, done.
    remote: Compressing objects: 100% (24028/24028), done.
    remote: Total 34230 (delta 22212), reused 15340 (delta 9324)
    Receiving objects: 100% (34230/34230), 202.53 MiB | 294.00 KiB/s, done.
    Resolving deltas: 100% (22212/22212), done.
    Checking connectivity... done.
    saifurs-Mini:YO-iOS saifurrahman$ cd iPhoneV1/
    saifurs-Mini:iPhoneV1 saifurrahman$ git checkout 1_4_0_content_discovery
    Branch 1_4_0_content_discovery set up to track remote branch 1_4_0_content_discovery from origin.
    Switched to a new branch '1_4_0_content_discovery'
    
    0 讨论(0)
  • 2020-11-22 00:35

    You can try

    git fetch remote
    git checkout --track -b local_branch_name origin/branch_name
    

    or

    git fetch
    git checkout -b local_branch_name origin/branch_name
    
    0 讨论(0)
  • 2020-11-22 00:36

    none of these answers worked for me. this worked:

    git checkout -b feature/branch remotes/origin/feature/branch

    0 讨论(0)
  • 2020-11-22 00:36

    The git remote show <origin name> command will list all branches (including un-tracked branches). Then you can find the remote branch name that you need to fetch.

    Example:

    $ git remote show origin
    

    Use these steps to fetch remote branches:

    git fetch <origin name> <remote branch name>:<local branch name>
    git checkout <local branch name > (local branch name should the name that you given fetching)
    

    Example:

    $ git fetch origin test:test
    $ git checkout test
    
    0 讨论(0)
  • 2020-11-22 00:39

    git fetch && git checkout your-branch-name

    0 讨论(0)
提交回复
热议问题