- Commands
- Step 1: Check SSH Keys on Your Machine
- Step 2: Generate an SSH Key for Your Business Account
- Step 3: Add the SSH Key to Your Business GitHub Account
- Step 4: Configure the SSH Config File for Multiple Accounts
- Step 5: Test the SSH Configuration
- Step 6: Clone the Repository Using the Business SSH Configuration
- Step 7: Move to the Repository
- Step 8: Confirm Everything Works
- Step 9: Verify the Setup
- Step 10:-Optional-Configure Global Identity and Repository-specific Identity
- GitHub Contribution Graph can be combined by setting the Noreply Email to be the same in both Your Repository or Globally
- (Optional) Use
.gitconfig
Includes for Easier Setup
git remote set-url
git remote set-url origin [email protected]:company/POSRetail_Php.git
- Open your Terminal.
- Run the following command to check if there are any SSH keys already on your Mac:
ls -al ~/.ssh
- Run the following command in Terminal to create a new SSH key:
ssh-keygen -t ed25519 -C "[email protected]"
- When prompted, save the key as:
/Users/amr.elghadban/.ssh/id_ed25519_business_amr_elghadban_adkatech
- Leave the passphrase empty (or add one for security).
- Result:
Your identification has been saved in /Users/amr.elghadban/.ssh/id_ed25519_business_amr_elghadban_adkatech Your public key has been saved in /Users/amr.elghadban/.ssh/id_ed25519_business_amr_elghadban_adkatech.pub The key fingerprint is: SHA256:4AAAAAAhXXXXXXXXXXDyK+M/L2bbbbSs [email protected]
- Copy the new public key to your clipboard:
pbcopy < ~/.ssh/id_ed25519_business_amr_elghadban_adkatech.pub
- Go to your GitHub Business account:
- Click your profile picture → Settings.
- Navigate to SSH and GPG keys under Access.
- Click New SSH key.
- Paste the public key into the "Key" field.
- Give it a meaningful title (e.g., MacBook Pro Business Key).
- Click Add SSH key.
- Open the SSH config file:
nano ~/.ssh/config
- If the file doesn't exist, create it:
nano ~/.ssh/config
- Add the following configuration:
# Personal GitHub Account Host github.aaakk.us.kg-personal HostName github.com User git IdentityFile ~/.ssh/id_ed25519 # Business GitHub Account Host github.aaakk.us.kg-business HostName github.com User git IdentityFile ~/.ssh/id_ed25519_business_amr_elghadban_adkatech
- Save the file:
- Press
Ctrl + O
, thenEnter
. - Press
Ctrl + X
to exit.
- Press
- Set correct permissions:
chmod 600 ~/.ssh/config
Run the following command to test the SSH connection:
ssh -T [email protected]
Expected Output:
Hi AmrAhmedElghadban! You've successfully authenticated, but GitHub does not provide shell access.
Use the business SSH alias:
git clone [email protected]:<company>/<reponame>.git
Do not use:
git clone [email protected]:<company>/<reponame>.git
- Decide where to move the repository:
mv ~/POSRetail_Php /Users/amr.elghadban/Desktop/workspace/project_folder
- Verify the move:
You should see the
ls /Users/amr.elghadban/Desktop/workspace/project_folder
project_folder
folder. - Navigate to the new location:
cd /Users/amr.elghadban/Desktop/workspace/project_folder/repo
- Check the Git status:
git status
- Ensure the remote origin is set correctly:
Expected Output:
git remote -v
origin [email protected]:<company>/<reponame>.git (fetch) origin [email protected]:<company>/<reponame>.git (push)
Ensure everything is working as expected.
- Set the identity for global Git identity:
git config --global user.name "Your Personal Name"
git config --global user.email "[email protected]"
- Confirm the settings:
git config --global --list
- Navigate to the repository directory:
cd /Users/amr.elghadban/Desktop/workspace/project_folder/repo
- Set the identity for this repository:
git config user.name "Amr Ahmed Elghadban" git config user.email "[email protected]"
- Check the repository-specific configuration:
git config --list --local
GitHub Contribution Graph can be combined by setting the Noreply Email to be the same in both Your Repository or Globally
git config --global user.email "[email protected]"
git config --global user.name "Amr Angry"
git config user.email "[email protected]"
git config user.name "Amr Elghadban"
If previous commits were made with the wrong email, you can rewrite them with the correct noreply email:
Then, force-push the changes:
git filter-branch --env-filter '
if [ "$GIT_COMMITTER_EMAIL" = "[email protected]" ]; then
export GIT_COMMITTER_EMAIL="[email protected]"
export GIT_AUTHOR_EMAIL="[email protected]"
fi
' -- --all
git push --force
Use .gitconfig
includes to manage multiple identities more efficiently.