<Tech>Brunch


Git issues with GUI Clients on MacOs Sierra 10.13

Lately, I changed my GitHub Username to ‘anshulgammy’. So as expected, urls of all of my repositories were affected. Most of the times, I make use of command line Git to push my changes. Nevertheless, I enjoy the ease that Git GUI clients have to offer.

I am using macOS sierra 10.13, and it had SourceTree installed for quite sometime. When I tried to push my changes to Git repo using SourceTree, it kept asking me for password for my previous username on host.github.com. However, I was able to push the changes from my Terminal, without any issues. It took quite long for me to figure out how to resolve this issue.


Source Tree Logo


In case you are also struggling with the same issue, here goes the solution:

  • Open KeyChain on your mac. Lock the KeyChain, and then unlock it.
  • Go to SourceTree, and make change to your Git Repository using the current username that you have on GitHub. You can change the URL from ‘Repository -> Repository Settings… -> Remote -> Edit.

The catch here was, SourceTree remembers the last username that was used to successfully log in to a given host and tries that one by default to look up the keychain entry. This can, however, be unreliable if you don’t use the same username all the time on a given host. To make it unambiguous, include the username in the URL, like this: http://username@host/path/to/repo

This resolved the issue with SourceTree, and now I am successfully pushing my changes using SourceTree.


GitHub Desktop


While I was struggling with SourceTree, I thought of trying a different GUI client - GitHub Desktop. Once installed, when I started it, it welcomed me with an error stating it cannot figure out my creds from KeyChain. The fix for this was simple:

  • Open KeyChain on your mac. Lock the KeyChain, and then unlock it.

Just doing this, fixed the issue with GitHub Desktop.