I work in a very large monorepo, so by default the fetch configuration is constrained to avoid pulling down thousands of branches and slowing down git (i.e. fetch = +refs/heads/master:refs/remotes/origin/master
)
If I want to pull down someone else’s branch, I can still easily do that by calling
git fetch origin <branch-name>:<branch-name>
which creates a remote branch and a local branch at the current state. However, it does not set up remote tracking between the two, so I cannot pull changes to the local branch.
I tried setting up remote tracking manually with git branch -u origin/<branch-name>
, but I get the following error:
fatal: cannot set up tracking information; starting point 'origin/<branch-name>' is not a branch
I see origin/<branch-name>
when I call git branch -r --list
and git show
works on it, so I’m perplexed by this error. Is there another way I can go about this without having to change the fetch config for that one branch?
Apologies if this is a duplicate question, I searched and could not find a definitive answer. Most don’t address the fetch config not including the desired branch. I tried the methods listed here. But I still get that same error.