I have cloned a repository, after which somebody else has created a new branch, which I'd like to start working on. I read the manual, and it seems dead straight easy. Strangely it's not working, and all the posts I've found suggest I'm doing the right thing. So I'll subject myself to the lambasting, because there must be something obviously wrong with this:
The correct action seems to be
git fetch
git branch -a
* master
remotes/origin/HEAD --> origin/master
remotes/origin/master
git checkout -b dev-gml origin/dev-gml
At this point there is a problem, for some reason after git fetch
I can't see the dev-gml remote branch. Why not? If I clone the repository freshly, it's there, so certainly the remote branch exists:
$ mkdir ../gitest
$ cd ../gitest
$ git clone https://github.com/example/proj.git
Cloning into proj...
remote: Counting objects: 1155, done.
remote: Compressing objects: 100% (383/383), done.
remote: Total 1155 (delta 741), reused 1155 (delta 741)
Receiving objects: 100% (1155/1155), 477.22 KiB | 877 KiB/s, done.
Resolving deltas: 100% (741/741), done.
$ cd projdir
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/dev-gml
remotes/origin/master
I've tried git update
, git pull
, git fetch --all
, git pretty-please
in all possible permutations...
write it from the terminal
it works fine.
To make it more specific Create a tracking branch, which means you are now tracking a remote branch.
After which you can
Then to work on that branch do
After you have made changes to the branch. You can git fetch and git merge with your remote tracking branch to merge your changes and push to the remote branch as below.
Hope it helps and gives you an idea, how this works.
We had the same problem and you have to use
Hope this help someone facing the same problem
The problem can be seen when checking the
remote.origin.fetch
setting(The lines starting with
$
are bash prompts with the commands I typed. The other lines are the resulting output)As you can see, in my case, the remote was set to fetch the master branch specifically and only. I fixed it as per below, including the second command to check the results.
The wildcard
*
of course means everything under that path.Unfortunately I saw this comment after I had already dug through and found the answer by trial and error.
I had to go into my GitExtensions Remote Repositories as nothing here seemed to be working. There I saw that 2 branches had no remote repository configured. after adjusting it looks as follows
Notice branch
noExternal3
still shows as not having a remote repository. Not sure what combo of bash commands would have found or adjusted that.I had this issue today on a repo.
It wasn't the
+refs/heads/*:refs/remotes/origin/*
issue as per top solution.Symptom was simply that
git fetch origin
orgit fetch
just didn't appear to do anything, although there were remote branches to fetch.After trying lots of things, I removed the origin remote, and recreated it. That seems to have fixed it. Don't know why.
remove with:
git remote rm origin
and recreate with:
git remote add origin <git uri>