After I enabled the “two-factor authentication“ on GitLab, I got the following error message when pushing changes to the remote Git repo:
remote: HTTP Basic: Access denied
After some research I realize some changes should be done to make it work.
First, you need to create an access token with the “read_repository/write_repository” permissions in GitLab. Then add the token into your remote repo’s HTTPS URL as below:
# 1. Remove the remote item first.
After that, I can push the changes successfully without “username/password” required.