I needed to have a local branch pulling and pushing to a remote branch of a different name. The pull is setup automatically after cloning and fetching. But the push was a little harder. I wanted this:
git push <remote> <localBranch>:<remoteBranch>
without having to worry about the local:remote every time. I’ve got all that working thanks to this blog post.
So as the blog explains, I set my global config to use the ‘upstream’ option by default. e.g:
git config --global push.default upstream
And it correctly pushes the local branch to the remote branch with just git push <remote>.
But when I do a git remote -v show <remote> on a remote with the default master branch as the upstream, I get the following:
* remote <remote>
Fetch URL: <giturl>
Push URL: <giturl>
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
myLocalBranch merges with remote master
Local ref configured for 'git push':
master pushes to master (local out of date)
Why does it still report the local ‘master’ branch as the source for pushing? It even says out of date (which it is if using the local ‘master’). Except doing the git push <remote> results in Everything up-to-date so it is definetly using the myLocalBranch correctly.
Am I misunderstanding something? Is this a bug in the git remote show command? Or have I got my config into a weird state?
Actually, the OP was under the false impression that the ‘
git remote‘ was mentioning master as the branch to whichmyLocalBranchwas pushing.This isn’t true: all that was displayed is that the local
masteris pushing to the remotemaster(probably set during the initial clone of the repo).The
branch.myLocalBranch.mergeconfig specific tomyLocalBranchisn’t listed by thegit remote.