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

  • 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
Add a Comment

Accepted Reply

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.

Replies

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.
  • Thanks. works for me.

Add a Comment
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

For me, it turned out to be an issue with the xcodeproj file AND settings. I removed the DVTSourceControlAccountDefaultsKey and also recreated my Xcodeproj from scratch. If you are doing a Swift package that does not require an xcodeproj then just delete it. Very annoying problem to deal with.