How to link same local folder to 2 different Netlify accounts

I have the same repository locally that I want to deploy in 2 different Netlify accounts.

When I build the app, I build for development as well as production, from the same local repository. Both of them differs by environment variables and some other setup.

Development one is for my personal development and experiments, and is in my personal email address. Whereas the production version is through a company’s email.

After building the app, I do “netlify deploy -p”. However, since I am using 2 different Netlify accounts, but there is only 1 “siteId” linked to the local folder, I am unable to deploy when I switch the netlify account due to Permission error.

Error: Not authorized to view the currently linked site (XX-XX)

How do I add the other “siteId” from the other Netlify account, so I can netlify deploy with the other account by simply switching over to it?

Ideally, what I want to do is:

  1. netlify switch → change the account
  2. It should also change the linked siteId
  3. netlify deploy → deploys the site

hi there,

I’m not quite sure this would work, but maybe you can achieve what you are trying to do with deploy contexts? :thinking:

scroll up a bit for a code example as well.

Hey @chique

There is a --site flag available for use with netlify deploy, so rather than having the site linked, you could pass the ID to the deploy command.

As an example:
Have two files which contain the API IDs: site-1, and site-2

Have the deploy command such as

nelify deploy --site `cat site-1`


SITE_ID=`cat site-2` netlify deploy --site $SITE_ID

You could create a shell function (e.g. ntldeploy) that accepts the filename as a parameter e.g.

function ntldeploy() {

  netilfy deploy --site `cat $1`

then type ntldeploy site-1 or ntldeploy site-2.

1 Like