Link to home
Start Free TrialLog in
Avatar of egoselfaxis
egoselfaxis

asked on

How do I change my Git user account login credentials?

I have Git installed on my Windows 10 PC, and have a fairly basic understanding on how to use it.  However, when I attempted to publish a project the other day, I learned that it wasn't actually configured with my personal github account. It was instead configured with an account that I'd set up for one of my client's projects that I worked on a few years ago.  I know this not only because I remembered it, but because even though the project seemed to be have been successfully published to a repo, .. it never actually showed up in my account.  It only showed up in my account when I installed and used "Github Desktop" to publish (configured with my personal Github account credentials).  

How and where can I change the login credentials for the command line version of Git that I have installed?  Should I uninstall and re-install it?  Or is there an easier way?

On a related note .. when using the command line version of Git, how do I create a new repository or specify which repository I want to publish a project to?  

Thanks,
- Yvan
Avatar of Daniel Pineault
Daniel Pineault

You should be able to run the following command

git config --global credential.helper wincred

Open in new window

Or if you're running windows 10 open the Credential Manager and they should appear there
Avatar of egoselfaxis

ASKER

I was able to locate a github account in the Credential Manager .. but the only one I see listed is the one for my personal account.  

How can I check to see what account my command line version of Git is connected to?
Does anyone else have any advice to offer?

- yg
Just to be sure.

There are two different things in github.

The repository url and the user credentials.

Example:
The repository url is for example
https://github.com/crossbario/crossbar

Open in new window


and the identity of the user pushing to it.

Often users fork a repository:
Example:
https://github.com/aalmazan/crossbar

Open in new window

is the url of the user aalmazan who cloned the crossbar repository.

Just to be sure, that your issue is really with the credentials and not with the repository url:

just enter your project directory and type
git remote -v

Open in new window

and show the output.

Perhaps it's the repository and not the credentials which are wrong
Concerning the question:
On a related note .. when using the command line version of Git, how do I create a new repository or specify which repository I want to publish a project to?  

the simplest way is to create the repository on github (with the correct account) and then just clone it with the clone url that you see on github.


If the project exists alraedy on your PC then it might be helpful to give us a little more context in order to avoid mixing up repositories
See https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup. Basically, your Git settings is stored at 3 places. You can see what information is located at which place by using the three commands:

git config --global --list
git config --system --list
git config --local --list

Open in new window


Concerning github, you probably want to have it as one of the remote repositories (possibly the upstream one). You can set/change the settings using the `git config`. If the remote repository (like github) wants some login, you will be asked for.
When I run "git config --global --list" via my bash terminal .. I'm definitely seeing the wrong username specified for user.name .. one that's different than the one I see listed in the Windows Credential Manager.  Why is that, and how can I change it?  

I've already tried re-installing the official version of GIT (I didn't un-install it first) .. but reinstalling didn't seem to do anything.  In fact, it didn't even prompt me to specify any github account login credentials during the re-installation.  

Any suggestions?

- Yvan
SOLUTION
Avatar of gelonida
gelonida
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The reinstalation of Git will not help you as the information is stored in the files that are kind of personal. This way they are preserved even after uninstall of Git. Try:
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

Open in new window


This is for the global settings. If you do the same for the --local, it will be bound to your local repository. In other words, it will override the global settings when working with that specific repository.

The Git Credential Manager for Windows is responsible only for authentication (simply said as if typing your password silently when working with GitHub). You may need to follow the https://github.com/microsoft/Git-Credential-Manager-for-Windows -- possibly to do something like
git config --global credential.helper manager

Open in new window

(I did not try).
Gelonida - when I enter my project directory and check the output of "git remote -v" .. I get the following:

origin  https://github.com/ygagnon/egoselfaxis-static-website.git (fetch)
origin  https://github.com/ygagnon/egoselfaxis-static-website.git (push)

The username that's specified here is correct .. but that's only because I ended up having to resort to installing and using Github Desktop to publish my project (which initially prompted me to log in to my preferred github account).  

I think that this other suggestion that you gave me might be the thing I should try next:


the simplest way is to create the repository on github (with the correct account) and then just clone it with the clone url that you see on github.

I'll post a followup here once I've tried that.  

Thanks,
-- Yvan
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Gelondia -- does "test" in this context indicate the specific user?   If not, then what exactly is it that I'm adding to the remote repo ?

My apologies .. I really never fully understood or particularly liked (or needed) Git, but I'm really trying to wrap my head around it.

- Yvan
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To add my experience with using the remote repositories. As gelonida wrote, when you clone the remote repository and say nothing, you get the local repository plus the working tree (copy of all files and the subdirectories). The original repository--that you cloned from--becomes the first remote repository, and it is named by default origin (the short, symbolic name). The short name is always bound to your local repository -- it is part of the configuration of the local repository.

When cloning from GitHub, I usually do git clone -o github https://ygagnon@github.com/ygagnon/egoselfaxis-static-website.git. Notice the -o github. Then you do not get the short name origin, you get the short name github instead. The alternative to get the same is to use git remote rename origin github.

To get the feeling for how you can use Git...

When working from my notebook, I have the working copy on notebook. However, I usually create also one remote bare repository located also on the notebook, and I give it the short name notebook. This is because I often work from my desktop computer joined to the same network. At the desktop, I have another working copy that is also joined to the bare repository repository on notebook, and it is also given the short name notebook. This way I can easily push/pull changes using the shared remote (bare) repository. In other words, I can easily ensure I have the same sources both on the notebook computer and on the desktop computer.

I often add also the remote named flash. This one points to my flash disk -- bare repository created there. If present, I can easily push/pull changes form the flash disk. At home, I also have the flash repo that points to the flash disk that I brought with me. So, I can easily transfer the work to/from my home computer.

Correction of my earlier post: I did use git remote -vv (with doubled v). I believe it work differently than -v in the past. It still works, but it seems to show the same as git remote -v these days.
Thank you both for your help with this.  I think I'm now getting the hang of it ... and I recently started tinkering with the source control featured of VS Code, which I think I'll likely migrate towards (instead of using the bash terminal).

Cheers,
- Yvan
In my opinion, the Visual Studio support for Git kind of obscures the natural way of using Git. The plain console commands for Git may not be suitable for beginners. It may be difficult to use them at fitst. However...

The standard distribution of Git contains two very nice "visual" tools that can be launched by the console commands: git gui and gitk --all. The tools may look a bit out-fashioned, but they really are very usable. Try them. ;)
backing up pepr about gitk --all . I'm not a graphical person and do almost everything via command line, but to understand complex projects gitk is a very helpful tool. tough it can not perform all tasks it can do perform quite a lot and helps understanding.