Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT pulling or cloning repository only gets Master branch

I host on BitBucket when I git clone a repository or use git pull origin master and git pull origin myBranch it does pull second time, but when I list branches with git branch -v I only see master. Doing git status shows nothing too.

How do I pull all of the branches off the web repo to my local repo?

Could it be that it's because I changed computers and name on the git settings changed so it only lets me get master since it's the default branch and the other one can be only accessed by whoever created it?

like image 230
JohnA Avatar asked Nov 03 '12 00:11

JohnA


People also ask

Does git clone only clones master branch?

The classic git clone command with the --single-branch option will clone only the master branch by default. If you want to clone another branch, you should add the --branch flag with the name of the desired branch.

Does cloning a repo get all branches?

The idea is to use the git-clone to clone the repository. This will automatically fetch all the branches and tags in the cloned repository. To check out the specific branch, you can use the git-checkout command to create a local tracking branch.

Does git pull pull master or the branch?

git pull origin master will pull changes from the origin remote, master branch and merge them to the local checked-out branch. git pull origin/master will pull changes from the locally stored branch origin/master and merge that to the local checked-out branch.


1 Answers

The branches do exist but you can't see them

Try using this:

git branch -a 

You'll now see the list of remote branches in origin e.g.

Output:

remotes/origin/tk_removes_call_centers remotes/origin/tk_warm_transfer_fix remotes/origin/update_README 

and you can then

git checkout [any_individual_branch_name] 

You can also get the same list with git branch -v --all which includes the most recent commit info, i.e.

git branch -v --all 

output:

remotes/origin/tk_removes_call_centers     1478b14 re-adding call feedback workers remotes/origin/tk_warm_transfer_fix        94720c5 handling blank auto policy remotes/origin/update_README               a769b82 Update README 

git branch -v (without --all) only shows branches you've worked on. When you use --all you see all the tracking branches in origin/

Related:

  • How to clone all remote branches in Git?
  • How do you create a remote Git branch?
  • Git fetch remote branch
  • How do I check out a remote Git branch?
like image 71
Michael Durrant Avatar answered Oct 08 '22 09:10

Michael Durrant