Add an additional git account in Mac

This article explains on how to set up an alternate remote url pointing to a different git account.

Add the username and password of your desired GitHub account

git config user.name mew_username
git config user.email new_email

git config -l

git remote set-url origin https://your_username@github.com/your_username/yourproject.git

List the configuration to display all the available accounts

git config -l
credential.helper=osxkeychain
user.name=Other Username
user.email=50510199+otherusername@users.noreply.github.com
core.autocrlf=input
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
user.name=new_username
user.email=new_username@email.com

Add a remote url with the new username

git remote set-url origin https://new_username@github.com/new_username/projectname.git

Now its safe too push to the remote repository

git push origin master

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s