If you prefer https instead of the SSH key solutions, the following works on Windows at least for Github (and in connection with TortoiseGit using a credential manager):
- In your local repository (or while cloning), set the remote (origin) url to
https://[yourusername]@github.com/[org]/[repo].git
(The important part here is the yourusername@github.com as this creates a git:https://yourusername@github.com
entry in the Windows credential store that differs from the regular git:https://github.com
entry that holds the credentials for all "regular" remote urls)
In case you want to edit it for an existing repository via the repo/.git/config
file, this is something like
[remote "origin"]
url = https://[yourusername]@github.com/[org]/[repo].git
fetch = +refs/heads/*:refs/remotes/origin/*
- Additionally, set the
credential
and user
properties in the repo/.git/config
file so your commits have the correct author:
[credential]
username = [Github-Username]
[user]
name = [Fullname]
email = [Email Address]
At your git remote operation (fetch, push etc.), you will be asked for authentication depending on your auth manager.