Xcode 12b - Push to git repository fails

Hi,

when I try to push to my git repository using Xcode 12 beta, I get the following error:

Code Block
An unknown error occurred
username does not match previous requests (-1)

It works correctly using Xcode 11, using the same copy / files on disk.

Is this a known issue?

Thank you,
Matthias

Answered by m.gansrigler in 621696022
just a quick update, this has now been resolved.
For future reference, this was caused by multiple entries for the same repository in Xcode's user defaults' DVTSourceControlAccountDefaultsKey.
What I did is remove them all and then do a pull for the repository in Xcode.
still the same in b2
is there anything I could be trying, like resetting Xcode's preferences, or a trick in the command line with xcrun, etc?
filed a bug: FB7899348
pushing via the command line works fine, by the way.
Accepted Answer
just a quick update, this has now been resolved.
For future reference, this was caused by multiple entries for the same repository in Xcode's user defaults' DVTSourceControlAccountDefaultsKey.
What I did is remove them all and then do a pull for the repository in Xcode.
problem occurs with released version of Xcode 12 also.
I have the same error from Xcode 12.0 (released version), but the difference is that I have no entries in DVTSourceControlAccountDefaultsKey (instead of multiple).

It worked fine in Xcode 11 (with an initial popup asking for my password), and it also still works fine using the git command line. Any help appreciated, because I do not like having to use Terminal for each git push.

git says it is using osxkeychain as credentials helper, in case that makes any difference.
Same problem with XC12 GM.
I tried to suppress DVTSourceControlAccountDefaultsKey from defaults with no success.
Then I
  • commented the [credentials] section in /Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig

  • restarted Xcode

  • and was able to access ONE repository, which recreated an entry in DVTSourceControlAccountDefaultsKey

This repository is now operational. But any other is not, even if it use the same credential. It looks like Xcode 12 has a bug in managing MULTIPLE entries in that key.




problem still occurs with the 12.0.1 update.

I have tried the various suggested workarounds but none of them work for me; although as noted by others the command line git push, pull, clone, etc work ok which indicates that the problem might be related to how the default credential helper (osxkeychain) works?

Any update on the status of your filed bug?
Same problem here. I fixed it by deleting my source control account from Xcode preferences, closing down Xcode, restarting Xcode, and adding my source control account again.
to  ehmjaysee: can you elaborate on what you did? What area of the Xcode preferences are you referring to? Not sure where to look for source control account information in the preferences (it's not in the source control general or git)?

thanks for any help
Fix for me was to set "Default Branch Name" = master (my old git repo uses master not main)

Xcode -> Preferences -> Source Control -> Default Branch Name

Pushing then prompted for username/password
problem still occurs with Xcode 12.1;
I tried fix suggested by curtly42 (changing default branch name to master) but this had no effect on the problem for me.
In terminal in project's directory try to run 'git pull', if it asks for a passphrase for key - then it's my case. Just enter 'ssh-add -K' and try git pull again. It shouldn't ask for a passphrase anymore. Restart Xcode.
Yes, the problem came back for me, too, in b3. Filed another bug report: FB8831714, it's really annoying.

What seems to help intermittently is to go through the steps of cloning the repository (without actually cloning it in the end). It works for the next 1-2 commits, then I have to do it again.
can I not remove the "mark as solved" badge? Ugh.
still the same in Xcode 12 b3. Unfortunately this problem also exists for Swift Packages which make them unusable for me. It is super frustrating and Apple does seem to care.
Still broken on 12.2b3.

Also with Swift Packages.

It is really frustrating that the Xcode team doesn't seem to care.
I ran into the same issue after wiping my machine. My two private packages became inaccessible within Xcode, but were otherwise perfectly reachable in other circumstances.

I was able to find a workaround. I had to do two things to get it working.

First, I changed from using an internal hostname to an IP address. It seems that whatever mismatch is happening is tied to the host name used. This might not be an easy change for you, depending on your configuration. But, it's at least a clue.

With this change, I was re-prompted by Xcode for authentication information and was able to point it to my ssh key. However, that wasn't quite enough.

I'd also begun using a new ssh key, with the ed25519 algorithm. This is recommended by GitHub, but apparently isn't supported by Xcode's internal git machinery. So, I created a new RSA key pair just for Xcode.

With a supported key and a new hostname, I was able to successfully fetch my private packages. I also verified that this *only* occurs with Xcode 12. Xcode 11 seems to have no problems with my original project and hostnames.
Still have problem with recently released Xcode 12.3
See my response over in https://developer.apple.com/forums/thread/665666

Bottom line is that you need to fix your ssh environment (if it's still broken), then delete the Xcode prefs file and reboot. Without rebooting Xcode is able to restore the broken ssh account/remotehost info and you get stuck with this error.
I've had some success using the notes provided by guyton (thank you). I have 2 machines which were both exhibiting this problem. I followed the same procedure on both:

created key pair and exported the public key to the remote server successfully
verified that I can access remote using command line git clone

With Xcode not running:

(1) delete the IDESourceControlKnownSSHHostsDefaultsKey using defaults utility:
defaults delete com.apple.dt.xcode IDESourceControlKnownSSHHostsDefaultsKey
(2) REBOOT machine
(3) start Xcode and attempt to clone a project

On one machine this worked perfectly - Xcode showed the dialog for picking ssh key pair to use and then cloned the remote project as expected. All other projects again allow remote push, pull, etc.

However on the other machine, I still get the -1 error. I suspect it has something to do with ssh environment but do not really know how to troubleshoot the problem. Any suggestions would be appreciated.

I also tried with deleting the entire plist from preferences and rebooting but that also did not fix the problem.

One last thing I did was to create (on the machine that has the problem) a new user account. In that account:
create rsa key pair
export public key to server
start Xcode and clone project - this worked without any problems
I tried a solution similar to that outlined by mattie; when logged in as the userid that shows the -1 error I edited a project's .git/config file and replaced the hostname for the "remote" server with its ip address (for me this was easy because the git server is in the same local network as my development machines). When I then opened the project in Xcode the git repository functions worked without errors. I then edited the config file again and changed the ip address back to the hostname and the Xcode git functions still worked!

For anyone who finds this in the future: What I had to do was to go my github email settings, and uncheck "Block command line pushes that expose my email." Xcode won't give you that specific of an error message, but pushing via command line will

What a pain, but what fixed it for me was:

Updating VSCodeCreating an SSH keyMove the SSH key to an accessible folder like your user folder "yourUserName/id_rsa.pub" instead of yourUserName/.ssh/id_rsa.pubAfter moving the id_rsa.pub I opened File->Preferences->Accounts, changed to SSH, selected the pub key and entered password
Xcode 12b - Push to git repository fails
 
 
Q