It is certainly a bug, ssh works with one of my machines but not the other. I solved it, follow these.
alternatively you can set remote to http by using this command in the existing repo, and use this command git remote set-url origin https://gitlab.com/[username]/[repo-name].git