How do I push to GitHub under a different username?
If you use different windows user, your SSH key and git settings will be independent.
If this is not an option for you, then your friend should add your SSH key to her Github account.
Although, previous solution will keep you pushing as yourself, but it will allow you to push into her repo. If you don't want this and work in different folder on the same pc, you can setup username and email locally inside a folder with git by removing -g
flag of the config command:
git config user.name her_username
git config user.email her_email
Alternatively, if you push over https
protocol, Github will prompt for username/password every time (unless you use a password manager).
This worked for me, it will prompt for username and password
git config --local credential.helper ""
git push origin master
You can push with using different account. For example, if your account is A which is stored in .gitconfig and you want to use account B which is the owner of the repo you want to push.
Account B: B_user_name, B_password
Example of SSH link: https://github.com/B_user_name/project.git
The push with B account is:
$ git push https://'B_user_name':'B_password'@github.com/B_user_name/project.git
To see the account in .gitconfig
$git config --global --list
$git config --global -e
(to change account also)