Using Git with Gitlab and second factor auth
PROBLEM: After 2nd factor activation on Gitlab, username and password auth is not working anymore
SOLUTION: Generate API key and use modified url
Generate your API key on Gitlab
You can find this option in Preferences > Access Tokens
Copy this token and note you will see it only once (you have to generate a new one if the old is lost)
Create new URL
1 |
So if you would like to push or clone the repo using e.g. git clone
, it should looks like this
1 |
Change .git/config
To keep remote origin
, adjust file .git/config like this
1 2 3 |
remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* |
or you can create new remote as well
1 |
but you have to use it when pushing like this
1 |
git push new-origin mybranch |
Working with IntelliJ IDEA/Webstorm
Just go to VCS > Git > Remotes… and change the URL of origin or add new remote and you should be fine 🙂