You can store the credentials in ~/.git-credentials as https://{user}:{password}@github.com and then add
[credential]
helper = store
to your ~/.gitconfig
EDIT:
I see you asked about gitlab and not github, my bad. I think the above solution should still work if you change github to gitlab, but I don’t know for sure
You can store the credentials in ~/.git-credentials as https://{user}:{password}@github.com and then add
what do you mean? For example if my username is “user1” and my password (or 2fa token) is “12345”, What do I write in my .git-credentials file? is it this?
[user]
name = Bob
email = bob@email.com
[github]
user = user1
password = 12345
[credentials]
helper = store