Need to change username in git pull

Answered

Hi,

I need to run git pull with another username than what is coming up as default in the ssh popup. Can this be configured somewhere? As it is now the ssh request popup presents my username in uppercase while the repository requires the username to be in lowercase.

Thanks,
Bengt

7 comments
Comment actions Permalink

Hi,

check the .git/config file for the URL of the remote repository. Probably you'll see the username in the URL there, and you can change it then.

0
Comment actions Permalink

For other people that had the same problem as I and the comment above did not help; try changing git global user config:

git config --global user.name "Sam Smith"
git config --global user.email sam@example.com

although I was trying to change git user when pushing.

6
Comment actions Permalink

The above commands change name and email used by git as the author when you commit.

They have nothing to do with SSH connection, which was the problem in the initial request.

0
Comment actions Permalink

That is true Dmitriy. My search led me here; So I was just trying to help people that like myself, did not know git author is what they should be looking for when you want to push with another user and not trying to help the original poster.

1
Comment actions Permalink

Ran into this problem today InteliJ 2019.1.  Looks like IntelliJ stores the git user name somewhere internally for the ssh git connection.  I couldn't figure out where IntelliJ stores the git user name.  I modified %USERPROFILE%/.gitconfig and IntelliJ would not pick up the new git user name.  I deleted %USERPROFILE%/.gitconfig.  Backed up my local changes using a .patch file.  Backed up changes I had on shelf using a .patch file.  Backed up shared runConfigurations (copied the folder from .idea).  Then I deleted the project folder in its entirety.  Opened IntelliJ and created the project again File -> New Project From Version Control -> Git.  Provided the ssh url to the git repo and Test the connection.  On my first commit I got the pop up to enter my user name and user email.  After that I was good.  Annotations picked up the new user name. 

Can someone from the the IntelliJ team clarify where the user name and user email from the the pop up gets stored?  I know it gets saved in %USERPROFILE%/.gitconfig but it is also saved somewhere else. Please provide the second location where the information is stored.

0
Comment actions Permalink

>  Looks like IntelliJ stores the git user name somewhere internally

IntelliJ relies on command line git, and git user name is determined by the git config. It is not saved in the IDE.

> or the ssh git connection

git username is not related to ssh connection. Git just calls the ssh client, which connects in accordance with its own settings, %USERPROFILE%/ssh/.config by default.

> I modified %USERPROFILE%/.gitconfig and IntelliJ would not pick up the new git user name

IntelliJ does not commit by itself, it just issues the git commit command and relies on git to determine user name. So probably different username was configured in the repository config. See https://git-scm.com/docs/git-config#_configuration_file

0
Comment actions Permalink

For me this was happening when doing Git: Update Project. I don't remember when it started happening because for a while I would just update from the command line with git pull, but at some point I got a bit annoyed. Turns out it was because in my project folder I had an old git repo from a previous project, that had a different user name:

project-root-folder$ grep my-username -R
cloudformation/.git/config: url = https://my-username@bitbucket.org/.../cloudformation.git

So all I had to do knowing this is to go PyCharm | Settings... and in the Version Control tab, and unregister that folder as a git root. Problem solved!

0

Please sign in to leave a comment.