I have a WSL Ubuntu 20.04 system where my username is firstnamelastname. On the server for our git repository however, my name is firstname.lastname.
This appears to confuse git a lot. Every time I try to pull, it keeps trying to do so as firstnamelastname, not the correct account with the period between the names.
What I have tried so far:
- Re-generating my SSH keys with
-C firstname.lastname
, thenssh-copy-id
‘ing them to the server - Setting my username with
git config --global user.name firstname.lastname
.
Neither of these have worked.
How do I fix this?
2
Answers
The
-C
just adds a comment to the key, it doesn’t change or set a username.Since you’re using an SSH key I’m assuming you’re using git over ssh. You should check to see what your remote is for the repository, as the username is normally embedded in the remote URL.
For example, on github the remote would look like
[email protected]:my_account/my_repo.git
. Note the username is set to git here, which is what github requires. You can set a remote to use any url and username you want.Run
git remote -v
to see your remotes. Then rungit remote set-url REMOTE_NAME NEW_URL
to change the remote and your username.Try configuring git and set your username as:
You can also configure your email address to match with your email address on your git server. That way it will associate the commits to your account.
Ref: https://git-scm.com/docs/git-config#Documentation/git-config.txt-username