-1

I have recently made a new github account and when I tried to push some files through git terminal into repository of my new account. it tells that I don't have access to the new account. So, I deleted the old credential of my previous account manually and saved the new one through git terminal. Now, it pushes the files into the repository of my new account with my old account (like as a contributor). So, I again deleted the credential of my new account manually from my pc and the git terminal show

The authenticity of host 'github.com (20.207.73.82)' can't be established.    
ED***** key fingerprint is SHA256:**some SHA256 code**.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

I even tried re-installing git terminal but it's still the same

phd
  • 82,685
  • 13
  • 120
  • 165
  • Did you add your public ssh key to your new GitHub account? – DudeGuy Mar 09 '23 at 03:44
  • In the settings of my old GitHub account, it shows there are no SSH key associated with this account – Jigyasu Tanwar Mar 09 '23 at 03:58
  • When you say you deleted the credential of your previous account, what credentials are you deleting, and where are you deleting them from? I'm not familiar with "git terminal" but the way that I authenticate with GitHub is by adding my public ssh key to my GitHub account, and then push and pull changes to and from GitHub on the machine with the matching ssh key. – DudeGuy Mar 09 '23 at 04:03
  • control panel > user account > credential manager > manage window credential. here I deleted my old github account credential associated with git terminal – Jigyasu Tanwar Mar 09 '23 at 04:05
  • Sounds like Windows, which I'm not familiar with. Maybe this will help. https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#authenticating-with-the-command-line – DudeGuy Mar 09 '23 at 04:24
  • https://stackoverflow.com/search?q=%5Bgithub%5D+The+authenticity+of+host+github.com+can%27t+be+established – phd Mar 09 '23 at 05:55

1 Answers1

3

note: the question is a bit fuzzy, I think the OP has an issue with credentials vs author. This is an answer to the question :
"I changed my github credentials, why are my contributions still linked to my old account ?"


There are two notions of "credentials", that are completely separate:

  1. one is the credentials you use to interact with github : it is represented by either the ssh key you use to connect over ssh, or the login:password (or variants ...) you use to connect over https
  2. the other is the name and email that appear in your commits in git -- the one you see when you run git log in your terminal for example -- you generally set it using git config user.name and git config user.email

You need 1. in order to do some actions on github: push to a repository, read from a private repository, etc ...

But 1. does not impact or modify 2. : you could perfectly be pushing commits written by Alice, and Alice could perfectly be pushing commits authored by you.

So even if you changed your credentials with github (that's 1.), your repo's history still mentions the same authors and committers (that's 2.). The information that github scans to say what counts as a contribution is 2., the email stored in the history of your repository.


  • If your intention is to keep the current history, and have new commits made with your "new" email address: just set the two git config parameters
git config user.name "updated name"
git config user.email "updated@email.com"

# if you want to apply this to all projects on your computer
# (at least: all the ones that do not have a local user.email config)
git config --global user.name "updated name"
git config --global user.email "updated@email.com"

# to check, within a repository, what email is used:
git config user.email
git config --show-origin user.email
  • If you want to have, on github, all contributions of the previous email linked to your new account:

in github GUI, go to your profile section and add that other email.
You may also need, if relevant, to delete your previous account.

  • If you can't (or don't want to) link both email addresses to your new github account, you may rewrite the history of your repository to change the author name

quoting the accepted answer to the question "How do I change the author and committer name/email for multiple commits?":

using git filter-repo, you can first install it and construct a git-mailmap according to the format of gitmailmap.

Proper Name <proper@email.xx> Commit Name <commit@email.xx>

And then run filter-repo with the created mailmap:

git filter-repo --mailmap git-mailmap

(note: the answer initially provided a working solution with git filter-branch, and then added an update when the git filter-repo tool was available. I am merely highlighting this part of the answer as it is IMHO, to this day, the most suitable way to do this)

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • There is the 3rd kind of SSH credentials — SSH host key. The error message is about that kind. The user needs to update `~/.ssh/known_hosts`. – phd Mar 09 '23 at 05:58
  • 2
    @phd: the OP's question is indeed fuzzy. I half-blind guessed that the OP seemed to have issues making the difference between credentials and author -- the hint is in the sentence "it pushes the files into the repository of my new account with my old account" -- so I wrote an answer to the question "I changed my github credentials but contributions still appear with my old account". – LeGEC Mar 09 '23 at 06:13
  • GitHub's logic is a bit odd, to be sure. I have two GitHub accounts. At my job, according to GitHub, the matt who writes and pushes commits and the matt who opens the PR and requests review and merges the PR are two completely different people. Personally I don't care. But I think I'll try your trick of adding the personal email to the work account and see what happens. :) – matt Mar 09 '23 at 11:50
  • No, GitHub wouldn't let me do that. The heck with it! – matt Mar 09 '23 at 12:00
  • @matt: I have a single account, so no account squatting on my work email, I guess this is why I could do it. – LeGEC Mar 09 '23 at 12:36
  • I could write my work email into the local (not global) git config of course. But then I'd have to remember to do that every time I clone this repo. – matt Mar 09 '23 at 12:39
  • Whoa, problem solved!!!! https://stackoverflow.com/a/46239540/341994 – matt Mar 11 '23 at 01:55