My IntelliJ IDEA was used by another user and when I try to push to Git, I was asked a password of this user.
How can I change user in my IDEA? I tried to change global Git user, but it is not working.
Go to the base directory of your project.
You will find a hidden directory called .git
. Enter into it.
There you will see a file called config
. Add the following code.
[user]
name = username
email = [email protected]
git config user.name "yourusername"
git config user.email "[email protected]"
Commented
Jun 29, 2021 at 6:23
You can change it global via any of the 2 options.
Use command :
git config --global user.name "John Doe"
Go to VCS -> Git -> Remotes
There you can edited your git remotes
by changing user in the URL https://user@serc-bitbucket.
In your next Push you'll be prompted to a dialog to enter your password, and in the next your credientials.
I found a solution myself: just find hidden .git file in your project root, open it, and change user.
I had faced similar challenge with changing my user, when I was pushing files directly from IntelliJ Idea and though the files were updated in GitHub it was being updated from a different account.
Turns out there's a file called .gitconfig in windows where the user name and email is stored.
C:\Users\<USER_DIR>\.gitconfig
[user]
name = <USERNAME>
email = <EMAIL>
Changing the email here changed my account.
Here the blog & a stack overflow question I used for reference.
Go to below link.
File-->Settings--->Version Control -->GitHub
If you need to connect to Bitbucket, you need to change the host to bitbucket.org
I did not quite like the previous answers, since one user was used for all projects, and it is not necessary to change it everywhere when changing the password.
C:\Users\{USER}\AppData\Local\JetBrains\IntelliJIdea2022.2\vcs-users\
Deleting the contents of this folder worked for me. I'm not entirely sure that this folder is responsible for storing information about git users, but judging by the name, this is it. Before deleting, just in case, make a backup of the folder.
P.S
C:\Users\{USER}\AppData\Roaming\JetBrains\IntelliJIdea2022.2\options\vcs.xml
It looks like just logins for different projects are stored here. But no password.
Just change in terminal in IntelliJ Idea an URL of your project. Put yours instead of ${urlToYourProject}
.
git remote set-url origin ${urlToYourProject}
Then update project (Ctrl+T). And you'll see the dialog where you can set your credentials.
Don't forget that you can use other remote name instead of origin
!
Update the user or the repo URL (depends what you really want to change) in you project by entering the .git folder (in your project) and modifying the "config" file respectively.
When using azure devops I needed to change the repo url which contained the token I had to change ;-)
If you are on a Windows machine and git is using the Windows credential manager, then you can change the username and password in the credentials manager:
To check if git is using the windows credential manager:
$ git config credential.helper
!"C:/dev/git-2.32/mingw64/libexec/git-core/git-credential-wincred.exe"
And to check if IntelliJ git is using the credential manager:
Go to File -> Settings -> Version Control -> GitHub and enter your Login and Password there.