1.) Revoke all rights for the key
Revoke all rights associated with this private key. This means, deleting it as trusted key from GitHub, your
.ssh/authorized_keys file, etc.. You will have to know where and how you used this private key.
2.) Terminate existing connections
For example, for SSH it is enough to reboot the machine. For GitHub, you may need to contact their support to see if someone else may have further compromised your account.
For other services, you need to figure this out on a case-by-case basis.
3.) Verify the attacker no longer has access
This means making sure that the attacker did not persist themselves further in your system. This could, for example, mean that they added new users, enabled SSH login for root with a pre-set password, installed other backdoors, etc.
Checking your log files will greatly help you, although you cannot be sure if an attacker has modified them.
My personal opinion is that it depends on what "sharing it with others" means. Did you just expose your private key, but didn't directly link to it in some way? If so, then two minutes is probably too short for anyone to notice.
Did you actively post your private key somewhere, such as Facebook? Then you might have a bit more of a reason to worry.