Git pushes HEAD -> master despite set-upstream-to and push.default

489 views Asked by At

I have a git repo in use without issue for a couple of years. I use SmartGit for convenience to do most things.

I recently noticed that while doing a push from SmartGit from dev branch, the dialog it presents for confirmation says "Push current branch 'dev' to 'master'" instead of dev to dev as was previously the case.

I switch to git cmd line to compare behavior and find that it also wants to push to master:

$ git push --dry-run
To https://github.com/some_repo.git
   c00bb9e..6a8ade4  HEAD -> master

Pushing with a refspec works as expected, but I cant seem to find a way to tell SmartGit to use that refspec or how it decides that it will be pushing dev -> master.

$ git push origin dev --dry-run
To https://github.com/some_repo.git
   428dd9b..6a8ade4  dev -> dev

Git status and refs show as expected:

$git status
On branch dev
Your branch is ahead of 'origin/dev' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean

$ git symbolic-ref HEAD
refs/heads/dev

My config push.default is set as 'simple' which should mean that current will push to same name on remote and complain if no match.

git config push.default
simple

I have also reset the 'upstream-to' and still a plain git push ends up wanting to do HEAD -> master.

$git branch --set-upstream-to origin/dev
Branch dev set up to track remote branch dev from origin by rebasing.

I'm out of ideas on what could be the cause of this and how to get back to a simple git push going to the branch matching current and/or how to get SmartGit to stop offering to push current -> master.

Git version: 2.5.0

SmartGit version: 8.0.3 #8135

1

There are 1 answers

1
Pockets On BEST ANSWER

From git-push(1):

When the command line does not specify what to push with <refspec>... arguments or --all, --mirror, --tags options, the command finds the default <refspec> by consulting remote.*.push configuration, and if it is not found, honors push.default configuration to decide what to push (See git-config(1) for the meaning of push.default).

It sounds like you have remote.dev.push set to HEAD.