Question

I'm performing a release of a project on Github using Maven. release:prepare fails with:

[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] remote: Permission to FOO/BAR.git denied to BAZ.
[ERROR] fatal: unable to access 'https://github.com/FOO/BAR.git/': The requested URL returned error: 403

The weird thing is that BAZ is the "wrong" github.com account. It is one of two user names I use on Github, but not one I have ever used with the BAR project. Let's say the right account is FIZZ.

SCM settings don't specify a user name:

<scm>
  <connection>scm:git:https://github.com/FOO/BAR.git</connection>
  <url>scm:git:https://github.com/FOO/BAR.git</url>
  <developerConnection>scm:git:https://github.com/FOO/BAR.git</developerConnection>
  ...
</scm>

(FOO is an organization that I'm part of.) In fact, I can't figure out where on earth BAZ is coming from. It's not in ~/.gitconfig or .git/config. There is no ~/.m2/settings.xml file. My Maven settings.xml file says nothing about Github.

If I use git on the command line it works -- push is fine for example.

Can anyone tell me where else this might be coming from? a hidden config file or directory somewhere, whether Maven- or Git-related?

Or, what's the best practice for recording the Github user to use in a private local file, like a Maven settings.xml or .git/config, such that I need not put my own user into the build file?

I'm using Mac OS X.

Was it helpful?

Solution 2

Finally figured this out. The problem is that I'm on OS X, and had logged in to my second account BAZ via Safari. This saved the username and password for https://github.com in Keychain. Apparently, the Maven SCM plugin consults this for HTTPS URLs, although git won't. After clearing Keychain, it correctly prompted me for a username and password.

OTHER TIPS

The simplest thing would be to explicitly use an ssh url, see more details in this answer.

git remote set-url origin git@github.com:FIZZ/FOO/BAR.git
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top