Reputation: 714
I have my local repo with *master tracking remote A's *master. (Remote A's *master is its only active branch.)
Remote B now has a *prbranch that has some extra work not in A/master. My local repo doesn't have any reference to any remote besides A (and my personal remote that is only used for pushing).
How can I a) fetch B/prbranch into my local repo and b) create a new local branch with the same name and changes automatically?
git fetch B prbranch
correctly fetches the branch, but puts it into FETCH_HEAD with which I have to manually create a like-named branch.
git pull B prbranch
is of course useless, trying to merge into the current local branch
and git clone --single-branch B prbranch
just makes a new repo in a subfolder of the current repo.
So how can I fetch the remote branch AND create an identical local branch in one command? Surely this isn't hard to do...
(My experience is of course limited, so I expect that the answer will be simple and "retroactively obvious".)
Upvotes: 3
Views: 1480
Reputation: 7368
The following command will fetch and create a local branch without creating a remote tracking branch:
git fetch <urlB> refs/heads/prbranch:refs/heads/prbranch
See Git Internals - The Refspec on the documentation.
Upvotes: 1