Somebody pushed a branch called test
with git push origin test
to a shared repository. I can see the branch with git branch -r
.
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
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'
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
none of these answers worked for me. this worked:
git checkout -b feature/branch remotes/origin/feature/branch
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
git fetch && git checkout your-branch-name