git - Check out a branch that exists in a remote -


i'm using git version 1.8.3.1 (centos 7). have repository on github bunch of branches. clone repository , attempt check out 1 of branches, won't let me:

$ git clone my_repo $ cd my_repo $ git checkout my_desired_branch error: pathspec 'my_desired_branch' did not match file(s) known git. 

i know branch exists in remote branch; pushed computer, , can check out on github no problem. reading on similar issues on stack overflow, answers seem variously consist of:

$ git fetch [--all] $ git pull [--all] 

however, none of these things solve problem. furthermore, no matter do, nothing except master branch shows when list branches:

$ git branch * master $ git branch -a * master   remotes/origin/head -> origin/master   remotes/origin/master $ git branch -r   origin/head -> origin/master   origin/master 

i can't fetch branch repo hash:

$ git fetch origin 6175e3ae4c88669af8aa5cd12b 

this command gives no output, --verbose... inspecting exit code shows it's 1. , of course:

$ git checkout 6175e3ae4c88669af8aa5cd12b fatal: reference not tree: 6175e3ae4c88669af8aa5cd12b 

this frustrating. @ point i've tried seemingly every possible combination of fetch, pull, , branch, , no matter do, can't local clone of repo show these branches exist, let alone let me check them out.

what happening here? seems simplest thing in world: given repo has branch want, clone repo , check out branch.

however, none of these things solve problem. furthermore, no matter do, nothing except master branch shows when list branches

from output posted, seems branch looking not present on remote server.

however, if present on remote server (let's name my_desired_branch) can make local branch (having same name) points remote branch using commands:

git branch my_desired_branch origin/my_desired_branch  git checkout my_desired_branch 

you can combine both of commands above using git checkout -b:

git checkout -b my_desired_branch origin/my_desired_branch  

if local branch my_desired_branch exists not connected remote branch can reconnect them using:

git branch -u origin/my_desired_branch my_desired_branch 

for more using git branch can read documentation or run git branch on command line.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -