Multiple RStudio projects in a single GitHub repo?



I’m doing some part time analysis work for an organization that uses GitHub to store shared scripts, data, and output files, but not really for development or version control. Right now it’s used kind of like one would use Dropbox. As such, they only have one repo for the whole organization and many subfolders for specific projects.

I really like the R Studio project/Git workflow and use it for my personal projects. But in those cases I use a new GitHub repo for each R Studio project. Is it possible to use multiple R Studio projects within a single repo? If not, any other advice for how to set the proper working directory (in a reproducible way) for a project that lives within a subfolder of a single repo?


Hey @mfherman - it is absolutely possible. My students submit work in a repo that is a bigger version of:

| DoeAssignments/
| ---- ProblemSets/
| ---- ---- PS01/
| ---- ---- ---- PS01.csv
| ---- ---- ---- PS01.Rproj
| ---- ---- ---- PS01.Rmd
| ---- ---- PS02/
| ---- ---- ---- PS02.csv
| ---- ---- ---- PS02.Rproj
| ---- ---- ---- PS02.Rmd

That said, if there is a lot going on - separate repos might be easier to work with in the long run?


Thanks! In this case how do you set up each of the R project files with a singe GitHub repo so you can use the git features in R Studio?

In the long run, it definitely would be better to make a new repo for each project, but since I’m just doing a little work for them, I probably won’t rock the boat too much :wink:


Thats a great question that I can't answer. I teach with GitHub Desktop instead of with the git tools in RStudio. So in that model, they are using the .Rproj files to set the working directory, but are tracking changes on the whole repo with another tool.

Perhaps someone else with more git+RStudio experience can chime in!


For the structure @chris.prener lays out, you'd have to have one project with its home directory at the top most level. That would then control the version control. Then that project could see changes below it and manage the repo. That's really not ideal, I think. The lower level projects would not be able to manage the git repo and the upper level could not open the lower level projects without borking paths... So, yeah you can do it, but it's not ideal.

Slamming all their junk into one repo is a bad design decision. But you kinda already get that, I think. To work within that confounded structure I think taking Chris' cue and using git desktop makes total sense. And just avoid the rstudio git integration when you work with that client.


Thanks for the clarification, @jdlong. I think that’s the way I’ll go for now. In the future, hopefully I can convince them change to one repo per project.