If you get fatal: remote origin already exists error. Check what origin is set up and remove it
git remote -v
git remote rm origin
Add remote origin for https. You can set up username:password in url but credentials will be seen plain text in git remote -v
git remote add origin https://username:passowrd@git.example.com/group1/project1.git
git remote -v
git push -u origin --all
git push -u origin --tags
I need to use \ after url and before group instead of :, otherwise I get an error URL using bad/illegal format or missing URL.
If you have special characters in password and get an error bash: !: event not found, for example, for '!' use '%21' (google for 'HTML URL encoding reference').
It is possible to add remote without credentials in url
git remote add origin https://gitlab.example.com/group1/project1.git
git config credential.helper store
git config --list
it will prompt for credentials on first login and should not afterwards. store option stores credentials same in plain text in ~/.git-credentials.
On Windows to store credentials in "Credential Manager"
git config credential.helper wincred
you can delete ~/.git-credentials then.
To clear credential helper
git config credential.helper ""