27Jul

Fix: Sourcetree “403 Permission Denied” when pushing to gitHub

I was using Sourcetree on a Mac and couldn’t push to GitHub with the correct access. The error like this in the log: fatal: unable to access ‘url’: The requested URL returned error: 403.

So this looks like an authentication problem (wrong username or password). But if you originally cloned the repo over SSH, the real cause can be something else: Sourcetree silently rewriting your remote URL to use HTTPS instead.

Why This Happens

When you connect your GitHub account in Sourcetree’s OAuth settings, it can end up pointing your local repository’s remote at an HTTPS URL (https://username@github.com/...) even though you set the repo up with SSH in the first place. Since your credentials and keys are configured for SSH, GitHub rejects the HTTPS push with a 403.

The Fix

Check your remote URL: either in Sourcetree under Repository > Repository Settings, or via terminal:

git remote -v

If you see something like:

https://username@github.com/username/repo.git

but you intended to use SSH, change it back:

git remote set-url origin git@github.com:username/repo.git

Or, if you prefer to stick with HTTPS, make sure Sourcetree’s stored credentials (or a personal access token) are actually valid. Go to Sourcetree > Preferences > Accounts, edit your GitHub account, and re-authenticate.

Hope this saves you time if you have the same issue.

Subscribe
Notify of

0 Comments
Oldest
Newest
Inline Feedbacks
View all comments