Change Git user in IntelliJ IDEA
JavaGitIntellij IdeaJava Problem Overview
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.
Java Solutions
Solution 1 - Java
-
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 below code.
[user] name = username email = [email protected]
Solution 2 - Java
You can change it global via any of the 2 options.
- "Git Bash" which comes with the git installation package.
- In IntelliJ View > Tool Windows > Terminal (Alt + F12).
Use command :
git config --global user.name "John Doe"
Solution 3 - Java
I found a solution myself: just find hidden .git file in your project root, open it, and change user.
Solution 4 - Java
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.
Solution 5 - Java
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
Solution 6 - Java
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.
Solution 7 - Java
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
!
Solution 8 - Java
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 ;-)
Solution 9 - Java
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:
Solution 10 - Java
Go to File -> Settings -> Version Control -> GitHub and enter your Login and Password there.