I've pulled all remote branches via git fetch --all
. I can see the branch I'd like to merge via git branch -a
as remotes/origin/branchname. Problem is it is not accessible. I can't merge or checkout.
This question is related to
git
repository
branch
git-branch
If you already fetched your remote branch and do git branch -a
,
you obtain something like :
* 8.0
xxx
remotes/origin/xxx
remotes/origin/8.0
remotes/origin/HEAD -> origin/8.0
remotes/rep_mirror/8.0
After that, you can use rep_mirror/8.0
to designate locally your remote branch.
The trick is that remotes/rep_mirror/8.0
doesn't work but rep_mirror/8.0
does.
So, a command like git merge -m "my msg" rep_mirror/8.0
do the merge.
(note : this is a comment to @VonC answer. I put it as another answer because code blocks don't fit into the comment format)
Maybe you want to track the remote branch with a local branch:
git branch new-local-branch
git branch --set-upstream-to=origin/remote-branch new-local-branch
git checkout new-local-branch
git pull
Whenever I do a merge, I get into the branch I want to merge into (e.g. "git checkout branch-i-am-working-in
") and then do the following:
git merge origin/branch-i-want-to-merge-from
Fetch the remote branch from the origin first.
git fetch origin remote_branch_name
Merge the remote branch to the local branch
git merge origin/remote_branch_name
Source: Stackoverflow.com