PyCharm/IntelliJ 403 Forbidden for git push -u origin master

Error 403 is very common error and can be caused by many different reasons. The solution of the problem will defer depending on the root cause of the issue. You can see related articles on these links:

PyCharm Github Push failed: Repository not found

PyCharm Bitbucket git credentials for Google account

Note that these solutions are working for github and bitbucket.
First I would open the PyCharm/IntelliJ Terminal and then I would check the local and the global user which are set for my project by:

Get local and global git info

  • local get
git config --get user.email
git config --get user.name
  • global get
git config --global --get user.email
git config --global --get user.name

Set local and global git info

  • local set
git config user.email myuser@xxxx.xxx
git config user.name 'XXX XXX'
  • global set
git config --global user.email myuser@xxxx.xxx
git config --global user.name 'XXX XXX'

Another way of checking the local user is by:

  • Open your project folder - right click on any file from your project

  • Show in Files

  • Go in the root folder

  • Search for ".git" folder (enable show the hidden files)

  • Open file config

  • Search for lines (or add them in order to set user and email for this project):

    [user]
    name = XXX
    email = myuser@xxxx.xxx

If the problem persist then you can check the remote repository used for the project by:

to

https://mycorrectuser@bitbucket.org/xxx/xxx.git

In case of the same problem I would recommend you to check the users stored in:

  • Main Menu
  • File
  • Settings
  • Version Control
  • GitHub

If you want to see what user and password should be used for git remote you can check the article above:

PyCharm Bitbucket git credentials for Google account

Related Article