Is the general rule: one workspace per one repo?


#1

hey all! quick question:

is it a best practice for me to create a new workspace everytime i clone a repo from github? is the general rule: one workspace per one repo?

right now, i have about 4 workspaces up and running, representing the 4 repo’s i’ve created/cloned thus far.

and i’m tempted to consolidate everything into 1 workspace, and putting each of my repos in its own directory.

but i fear that’ll give me the “repo within a repo” problem that i was warned not to do. (i’m a new developer and learning how to program).

what’s the rule of thumb about whether i should create a new workspace in cloud9 whenever i clone/create a r?

thank you in advance for your help :0)


#2

In my opinion, the easiest way with c9 is to have one repo per workspace. Then you don’t have any issues of dependencies between different projects, and they stay self-contained. You can create another instance at the click of a button, and have a clean workspace ready to go which helps. It’s one of the many advantages of a cloud based IDE.

Of course, I might be slightly biased.


#3

hey @mutahhir here’s my thread with my question. thanks again!


#4

I agree with @justin8 that one repo per workspace is a very cool experience.

Creating a workspace for a repo is like having a laptop just for working on a specific project, and then switching laptops to work on another workspace. Which is awesome, and Cloud9 lets you do that with a click of a button.

In some scenarios, however, you might want to work on multiple projects at the same time. For example, you’re developing a web service, and a command line app that need to talk with one another. Although they are part of the same project, they might have separate repositories, and different people working on them.

What’s the best way to proceed in that scenario?

You can still have one workspace per repo, and just open each in a new tab, which is almost instant, and allows you to context switch instantly. However, you might not prefer that.

So, coming to how to set up a Cloud9 workspace for multiple repos. Here are some considerations:

  • Don’t create a workspace by cloning a repo. That will make the ~/workspace folder contain the repository you cloned. Anything you clone within a subdirectory will be added to the main repo.
  • Create a workspace without cloning, preferably using the ‘Custom’ type, so you have an almost empty ~/workspace folder.
  • Now, within the ~/workspace folder, you can clone git repositories and each will have their own folder

With the workspace-per-repo setup, you never have to worry about which git repository you’re committing to, but in the multiple-repo-per-workspace setup, you actually do. Say you have the following setup:

- ~/workspace
  - repoA
  - repoB
  - repoC

If you run git ... on ~/workspace, you’ll get an error as ~/workspace doesn’t have a git repo. Going to repoA will allow you to modify the repository there, and going to repoB will modify a different repository. So, you’ll have to be careful about where you’re committing / pushing etc.

This is also a very good reason for going for the workspace-per-repo setup, as it frees you from thinking about this, and also just works.

I hope this helps.

Regards,
​Mutahhir


#5

thanks @justin8!! when you say “create another instance” , you mean create another workspace, right?


#6

thank you so much @mutahhir and @justin8! you both have sold me on the workspace-per-repo setup :0)

i thought i was being lazy/inefficient by having multiple workspaces, but i’m glad to learn that’s the best, most seamless way to do it. thanks again :0)


#7

Hi Diana,

I just did a quick count - I currently have 16 workspaces :blush:.

Having multiple workspaces is the way to go - this way you can “freeze” your project in time and don’t need to be afraid that this one “npm install” or update to PHP6 or Python 3 is going to break your older projects.

A year ago I helped a friend with his Wordpress website. We hardcoded some stuff and now he quickly needed to change that - I opened up my workspace and there it was - tab still open and all :slightly_smiling:

Cheers,
Matthijs