6

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.

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Excellent. Each .git file being self-contained and having no knowledge of other .git files out there makes a lot more sense now. Thanks.
3

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.

Comments

2

All Git's information is held in a .git directory in the top of the working copy. So if you are working on two different projects, you would create clones in two different directories on your local system. Each one would have a remote that points to its corresponding project on Github.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.