Managing two Github accounts from Rstudio

Hi!

Is it possible to set two github accounts in Rstudio? Or in another word, I have personal and work github accounts and I want to be able to separate the two accounts when working with projects.

Thanks!

1 Like

This project could be of interest

Not sure it applies fully in your case but may be adapted to fill your need. It implements special github functions for another github server with another github TOKEN.

BTW, you can set any github accounts you want with RStudio. You just have to configure GIT in your project to work with the account you want for the specific project.
For installing from Github with install_github, you can use several token saved in different env var and pass them as argument in the functions to use one or the other. This should work with gh :package: too.

I may have misunderstood what you meant by two github accounts in RStudio. If so, please give precision on what you want to do.

1 Like

I think the correct solution is to make use of project .gitconfig files. When you use git it looks for a local .gitconfig, it that doesn't exist, it looks for a global .gitconfig.

So in your case, you could create a local .gitconfig whenever you are using your personal repos and rely on the global config for work.

See for example https://coderwall.com/p/wkqf9q/local-global-git-config

2 Likes

Thanks for the answer, I will check it. Just to clearify, I want to be able to spearate between personal and work related projects while working with a single machine. I have two users accounts (personal and work), I wasn't sure if I define for each project a specific user according to the project uses (either personal or work).

Thanks! I will check it

It is what I would do. In each project, configure a different GITHUB Token in R Session (Rstudio Project) if personnal or work project. The use of local .gitconfig is also an option but I was not aware (and still not sure) you could use it for GITHUB account credential.

1 Like

Another option I've just stumbled on is to use the environment variable GIT_SSH_COMMAND . You would add this to you Renviron file located in your project directory. More details at superuser

1 Like