If you are using the terminal to push your most recent git changes to gitlab and run into this error: HTTP Basic: Access denied, follow these steps:
I. Set global username(optional):
- Download or close your repo [git clone https://gitlab.../yourproject.git]
- Set your repo origin if neccesary
$ git remote set-url origin https://git-repo/your-gitlab.git
- From the terminal or command line, run this command:
git config --global user.name "https://[YOUR-USERNAME]@gitlab.com/neybapps/[YOUR-GITLAB-REPO].git"
II. Create a personal access token:
- Navigate to GitLab
- Type your credentials
- On the top right corner, click on your profile icon
- Select
Edit Profile
- On the left hand side navigation, select
Access Tokens
- Under
Token name
type whatever you want to name the token - Scroll down and
Select scopes
- Under
Select scopes
, selectread_repository
,write_repository
, and any other desired scope - Scroll down below
Access Tokens
section and click onCreate personal access token
- Copy the link and save it in a safe place
- Make sure you remember where you place it
III. Push changes
Return to your code terminal in your local machine
Follow the steps to push your changes to gitlab:
1. git checkout -b [YOUR-BRANCH] origin/[YOUR-REMOTE-BRANCH]
2. git add [YOURFILES]
3. git commit -m "name your changes
4. git push origin [YOUR-BRANCH]
- If you are using VSCode, you will receive a prompt message to enter the previous personal access token. Note: You might need to enter your username again
- Enter your access token and hit enter [DONE]