its_me
its_me

Reputation: 11338

Changing GitHub User 'Name' (not to be confused with 'Username') via Command-line?

I am following the quite-easy-to-understand Git Immersion tutorial to get started, as am using Git for the very first time.

And the very first command had me in doubt. I issued the commands exactly like this:

# To login
$ ssh -T [email protected]

# To change my name
$ git config --global user.name "Joana Dine"
$ _

After all that, when I check my GitHub account, it's still the same old name. My name did not get updated. What am I doing wrong?

Upvotes: 3

Views: 2758

Answers (2)

Daenyth
Daenyth

Reputation: 37431

If you want to change the ones on github you need to rewrite your entire repo history (destructively) - see this guide

As others have said, git config uses that name information to supply the "author" field for new commits you make - it doesn't have any effect on history.

The reason it doesn't change anything in the past is because the commit author is one of the fields used to generate the hash of the commit - changing it would change the commit's identity.

Upvotes: 2

VonC
VonC

Reputation: 1323125

I confirm:

git config --global user.name "Joana Dine"

This is only one of the three place Git will look for for identifying your commit done locally (on your workstation).
This is not related to GitHub.
This is related to the commit author and committer name for each of the commit you are creating locally.

If you want GitHub to show said commits as yours, once pushed on your GitHub repo, then sure, you should set your user.name and user.email to the same values than the one associated with your GitHub account.

But nothing prevent you to make commits as "foo" (git config --global user.name "foo"), and then pushing them using your GitHub credentials.
The two (commits name and GitHub credentials) aren't linked at all.

The "To change my name" should be understood as "To change my name locally for my new commits".

The only time GitHub will need credentials is when you are pulling/pushing a GitHub repo, in which case it will use the credentials used in $HOME/.netrc (or %HOME\_netrc on Windows, provided you did defined HOME, which isn't defined by default on Windows): see "Syncing with github".

Upvotes: 2

Related Questions