How to remove offending key in git when you try to push your changes?

It says:

Offending key for IP in /home/alireza/.ssh/known_hosts:10

So for some reason you have to delete 10-th line in known_hosts.

Run this command to delete 10-th line in known_hosts:

sed -i '10d' ~/.ssh/known_hosts

Or use ssh-keygen

ssh-keygen -R git.mywebsite.ir

Quote from man

 -R hostname
         Removes all keys belonging to hostname from a known_hosts file.
         This option is useful to delete hashed hosts (see the -H option
         above).

Tags:

Git

Ssh