DEV Community

Cover image for How to Effortlessly Manage Multiple Accounts in GitHub Desktop (macOS)
چودھری یاسر علی
چودھری یاسر علی

Posted on Edited on Fully Autonomous

How to Effortlessly Manage Multiple Accounts in GitHub Desktop (macOS)

Update (20th October, 2026): This guide has been improved to fully sync your terminal Git identity with GitHub Desktop. The gitsave command now prompts for your Git user.name and user.email, automatically injecting them into your new alias so your terminal commits always match your active profile. It also ensures all generated aliases are neatly grouped together in your .zshrc file for easier management, and includes a new gitdelete function to safely remove old profiles.

Disclaimer: This guide and the accompanying scripts were generated with the assistance of AI. While the workflow has been tested, please double-check all terminal commands and scripts before running them on your own system.

If you use GitHub Desktop, you probably love its clean UI and seamless conflict resolution. But if you are a freelancer, an agency developer, or just someone juggling personal and work repositories, you’ve definitely hit its biggest limitation: GitHub Desktop does not natively support multiple accounts.

While there is a massive official feature request for this that has been active for years, the maintainers unfortunately have it tagged as not-planned for the foreseeable future.

If you want to switch from your personal account to a client’s account, you have to manually sign out, sign back in, and re-configure your Git identity every single time.

After getting frustrated with this, I built a fully automated terminal workflow for macOS that lets you swap GitHub Desktop profiles and Git identities in a split second using a single command.

Here is how you can set it up.

The Core Concept: The Symlink Trick

(Credit where credit is due: The foundational idea of swapping configuration folders via symlinks was inspired by this clever Stack Overflow answer. I’ve expanded on that concept here to include global Git identity swapping and a fully automated profile generation script.)

GitHub Desktop stores all of its session data, login tokens, and preferences in this directory: ~/Library/Application Support/GitHub Desktop

By renaming this folder (e.g., to GitHub Desktop.config1) and creating a symbolic link (symlink) in its place, we can trick the application into loading different profiles whenever we swap the symlink out.

Even better, we can chain this with standard git config commands so that your commits always use the correct email address for the active profile!

Step 1: Add the Automation to Your .zshrc

Instead of doing this manually every time, we are going to add aliases and a smart bash function to your terminal configuration.

Open your terminal and edit your zsh configuration file:

nano ~/.zshrc

Enter fullscreen mode Exit fullscreen mode

Paste the following code into your file:

# =========================================================  
# 1. GITHUB DESKTOP & GIT IDENTITY SWITCHERS  
# =========================================================  
alias gitpersonal='ln -nfs "$HOME/Library/Application Support/GitHub Desktop.config1" "$HOME/Library/Application Support/GitHub Desktop" && git config --global user.name "Your Name" && git config --global user.email "personal@email.com" && echo "Switched to (Your Name) Config 1"'  
alias gitwork='ln -nfs "$HOME/Library/Application Support/GitHub Desktop.config2" "$HOME/Library/Application Support/GitHub Desktop" && git config --global user.name "Work Name" && git config --global user.email "work@company.com" && echo "Switched to (Work Name) Config 2"'  

# =========================================================  
# 2. PROFILE MANAGEMENT AUTOMATION  
# =========================================================  
# Command to un-link and prepare for a fresh login
alias gitnew='rm -rf "$HOME/Library/Application Support/GitHub Desktop" && echo "Delinked! Open GitHub Desktop to set up a fresh profile."'

# Command to save a newly created profile and generate an alias automatically
gitsave() {
  if [ -z "$1" ]; then
    echo "Usage: gitsave <alias_name> (e.g., gitsave gitclient)"
    return 1
  fi

  local target_dir="$HOME/Library/Application Support/GitHub Desktop"

  if [ -L "$target_dir" ] || [ ! -d "$target_dir" ]; then
    echo "Error: No fresh setup found. Run 'gitnew', open GitHub Desktop, log in, close it, and try again."
    return 1
  fi

  echo -n "Enter Git User Name for this profile (e.g., John Doe): "
  read git_name
  echo -n "Enter Git Email for this profile (e.g., john.doe@example.com): "
  read git_email

  local num=1
  while [ -d "${target_dir}.config${num}" ]; do
    ((num++))
  done

  mv "$target_dir" "${target_dir}.config${num}"
  echo "✅ Saved current profile as config${num}"

  # Construct the alias with consistent echo formatting
  local new_alias="alias $1='ln -nfs \"$target_dir.config${num}\" \"$target_dir\" && git config --global user.name \"$git_name\" && git config --global user.email \"$git_email\" && echo \"Switched to ($git_name) Config ${num}\"'"

  # Insert the new alias into .zshrc right above the gitnew alias
  awk -v new_alias="$new_alias" '/^alias gitnew=/ {print new_alias; print ""; print $0; next} 1' ~/.zshrc > ~/.zshrc.tmp && mv ~/.zshrc.tmp ~/.zshrc

  echo "✅ Added alias '$1' to your .zshrc"
  source ~/.zshrc
  echo "🎉 All done! You can now use '$1' to switch to this profile."
}

# Command to safely delete an old profile and its alias
gitdelete() {
  if [ -z "$1" ]; then
    echo "Usage: gitdelete <alias_name> (e.g., gitdelete gitclient)"
    return 1
  fi

  local alias_name="$1"
  local alias_line=$(grep -E "^alias ${alias_name}=" ~/.zshrc)

  if [ -z "$alias_line" ]; then
    echo "Error: Alias '$alias_name' not found in ~/.zshrc"
    return 1
  fi

  local config_suffix=$(echo "$alias_line" | grep -oE "\.config[0-9]+")

  if [ -n "$config_suffix" ]; then
     local target_dir="$HOME/Library/Application Support/GitHub Desktop"
     local full_path="${target_dir}${config_suffix}"

     if [ -d "$full_path" ]; then
         rm -rf "$full_path"
         echo "🗑️  Deleted folder: $full_path"
     fi
  fi

  # Safely remove the alias line from .zshrc
  sed -i '' "/^alias ${alias_name}=/d" ~/.zshrc
  echo "✅ Removed alias '$alias_name' from ~/.zshrc"

  source ~/.zshrc
  echo "Done!"
}

Enter fullscreen mode Exit fullscreen mode

Save the file (Ctrl + O, Enter, Ctrl + X) and reload your terminal:

source ~/.zshrc

Enter fullscreen mode Exit fullscreen mode

Step 2: How to Use Your New Superpowers

Now that the code is in place, managing your accounts is incredibly simple.

Switching Between Existing Profiles

Ensure GitHub Desktop is closed. Open your terminal and type your alias:

gitwork

Enter fullscreen mode Exit fullscreen mode

Boom. You are now logged into your work account, and any commits you make will automatically be attributed to your work email. Need to switch back? Close the app, type gitpersonal, and you're done.

Adding a Brand New Profile (The Magic Workflow)

This is where the gitsave function shines. Let's say you just landed a new freelance client and need a dedicated GitHub account for them.

  1. Close GitHub Desktop.
  2. Run gitnew in your terminal. (This safely unlinks your current profile).
  3. Open GitHub Desktop. It will act like a brand-new installation! Log into your new client account and set up your preferences.
  4. Close GitHub Desktop.
  5. Run your save command with whatever shortcut name you want to use: gitsave gitclient
  6. The terminal will ask you for the Git Name and Email you want to associate with this specific client.
  7. Run your newly created command to activate the profile (e.g., gitclient).
  8. Open GitHub Desktop. You are good to go!

The script will automatically move the folder to the next available slot (like config3), dynamically write the new alias into your .zshrc file, and reload your terminal. You can now type gitclient anytime you want to work on their codebase!

Safely Removing an Old Profile

If you no longer need a specific GitHub profile or made a mistake during setup, you can cleanly remove it using the gitdelete command. This function safely deletes the hidden configuration folder and automatically removes the alias from your .zshrc file.

  1. Open your terminal.
  2. Run the delete command followed by the alias you want to remove:
gitdelete <alias_name>

Enter fullscreen mode Exit fullscreen mode

(Example: gitdelete gitclient)

  1. The script will locate the correct .config folder, delete it, strip the alias line from your setup, and reload your terminal automatically. You will see a confirmation message once it is completely removed.

Wrapping Up

Until GitHub officially supports multi-account management in their desktop client, this symlink trick is an absolute lifesaver. It keeps your identities perfectly separated and completely removes the friction of logging in and out.

Let me know in the comments if this workflow helped you clean up your Git environment! 🚀

Top comments (0)