skip to Main Content

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, then ssh-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


  1. 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 run git remote set-url REMOTE_NAME NEW_URL to change the remote and your username.

    Login or Signup to reply.
  2. Try configuring git and set your username as:

    git config --global --add --user.name firstname.lastname
    

    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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search