Last active
April 7, 2020 08:54
-
-
Save mtilson/95104660b3819519a26ec30c29a0c663 to your computer and use it in GitHub Desktop.
how to set Git repository and global options for multiple GitHub accounts [git] [github]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# let's say we have GitHub 'org' with 'team' of 2 members | |
# ('member1', 'member2') having Write access to | |
# 'repo' with URL of 'https://github.com/org/repo.git' | |
# we are going to setup repository and global Git options | |
# (on macOS) to be able to commit to 'repo' using the | |
# above GitHub user accounts including different network | |
# authentication | |
# configure system credential helper (e.g. for macos) | |
git config --system credential.helper osxkeychain | |
git config --system credential.usehttppath true | |
# remove user personal name and email from system configuration | |
git config --system --unset user.name | |
git config --system --unset user.email | |
# for 'member1' account | |
# clone repo | |
mkdir member1 | |
cd member1 | |
git clone https://github.com/org/repo.git | |
cd repo | |
# setup user personal name and email | |
git config user.name member1 | |
git config user.email member1@email.io | |
# setup authentication credentials | |
git config credential.username member1 | |
# repeat the above steps for 'member2' account | |
cd ../.. | |
# clone repo | |
mkdir member2 | |
cd member2 | |
git clone https://github.com/org/repo.git | |
cd repo | |
# setup user personal name and email | |
git config user.name member2 | |
git config user.email member2@email.io | |
# setup authentication credentials | |
git config credential.username member2 | |
# now the corresponding user names/emails, and configured | |
# credential names are stored in the repo's '.git/config' | |
# and will be used by Git to push commits to GitHub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment