Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having multiple Git repositories

Tags:

git

github

This seems like the simplest Git question, but I can't find ANYTHING on it.

So for a newbie to Git, I know how to add, commit, and then push files to my GitHub account. But how do I then create a new project and switch between working on that repository and my old repository? Will cd'ing to the appropriate directory and then remote adding each time work, or could I just cd and push immediately? That seems really tedious. I think I'm missing a fundamental point of Git.

like image 997
telkins Avatar asked Jun 18 '12 03:06

telkins


People also ask

How many Git repositories can I have?

Theoretically, everyone can has an unlimited number of public and private repositories even as part of a free plan. Public repositories don't have officially any restrictions even as part of a free plan. Save this answer.

When should I use multiple repositories?

Having multiple repositories makes it easy to give access to subsets of repositories on a “need to code” basis. I set up Continuous Deployment for my projects. It's much easier to let each repository have it's own process for being deployed.


2 Answers

A git project is fully self-contained within its root directory, so cding to another directory with its own git project is switching to another project.

As to the Github part:

Github hosts a copy of the repository for each project, so it makes sense that you have to setup the remote links for each project - they have nothing in common with each other, so they each need the remote link to the repository on Github.

like image 188
andrewdotnich Avatar answered Sep 22 '22 12:09

andrewdotnich


It's just as everyone else described it. A git project contains all sub-directories and files in the directory that has the .git folder (well, all the files that aren't ignored, anyway). There are times, however, when you'll want to have a git repository inside another one though. The way to go about this is to use submodules.

like image 21
bilalq Avatar answered Sep 20 '22 12:09

bilalq