Reputation: 121
My co-developer made a lot of changes on his remote gitlab repository: merged, deleted, created new branches etc.
Now I need to work on a new feature branch that he's just created. I open my Gitbash, do:
git pull [email protected]:root/project-name.git
git checkout new-feature
I get error: pathspec 'new-feature' didn't match any file(s) known to git.
Then I tried:
git show-ref
This only shows two branches, while it should show at least 8. I also tried fetch which made no difference whatsoever.
Are the files really missing or is it simply not tracking the new branches?
How do I get the new branch to my local workspace?
Would git clone
solve it or only make it worse? Thanks.
UPDATE: Thank you for your help, unfortunately, neither of the suggestions worked and I had to delete everything, set it up from scratch and do a fresh git clone. We looked through the error logs but didn't find any clues. Just one of those things, I guess.
Upvotes: 2
Views: 9478
Reputation: 151
I know this is an old thread, but I just stumbled over it because I had the same problem. After checking 'man git' I found out that 'git fetch' does the trick. So, for anyone who might come across this topic in the future:
git fetch
.As the description of git fetch
states:
Fetch branches and/or tags (collectively, "refs") from one or more other repositories, along with the objects necessary to complete their histories. Remote-tracking branches are updated (see the description of below for ways to control this behavior).
Upvotes: 5
Reputation: 9488
You need to give a name to the repository first:
git remote add somerepo [email protected]:root/project-name.git
Then when you do a pull git will store the remote tracking branches in somerepo/new-feature, and when you do git checkout new-feature
it will create a new local branch based on that.
When you do git pull <url>
only the HEAD is fetched, and it's stored in FETCH_HEAD, which is probably not what you want.
Upvotes: 0
Reputation: 2814
You can try getting the branch on remote
git checkout origin/branch-name
Also, we use network graph in gitlab UI heavily to check any inconsistencies with the branch.
Upvotes: 0