Error message 'Authentication failed on the git remote'

I solved it by following Caching your GitHub password in Git.

The steps are as follows:

  1. Download and install Git for Windows
  2. Run Git Bash, 'cd' to the repository directory and enter git config --global credential.helper wincred

I believe I have found a solution to this problem. None of the solutions above worked for me. I think the root cause of this issue is that GitHub has ended support for password authentication on August 13, 2021. Instead a personal access token needs to be used.

The steps to solve this issue are as follows:

  1. Create a personal access token on GitHub.com. Tutorial here
  2. Go back to Visual Studio Code and open terminal. Type in the following command with your own user information:
git remote set-url origin https://<TOKEN>@github.com/<user_name>/<repo_name>.git

In case you would like to follow a video guide, this one proved to be quite helpful.