views:

259

answers:

3

Hi, I just started using Git and I want to know if this is the right way of using it. I started a Rails app with:

rails newapp

Then I did:

cd newapp
git init
git add .
git commit -a

So is it "right" to init my git inside my working directory?

A: 

Yep. Looks good to me.

Squeegy
A: 

Yes. In a DCVS like git, your working copy is your repository.

Thomas
The working copy is not the repository - at least, not to my way of thinking. The stuff under the .git directory is the repository, isn't it?
Jonathan Leffler
Well, yes. But they can't be in completely distinct places, like in centralized versioning systems such as Subversion and CVS. Also, in git it is possible to have a 'bare' repository without a working copy, but I didn't want to mention that.
Thomas
+7  A: 

Yes. You can place a git repository anywhere - including the invisible .git directory created by another git repository. I have a friend who has git track all his system config files in case he makes a mistake.

When working on a project, you want to init your repository in the root directory of the project.

To elaborate, each "working copy" of a Git repository is itself a Git repository. If you have a remote copy on a server, that is also a repository. You don't "check out" from there - rather, you "push" your changes and they are merged. If working on a purely personal project, the remote repository is often unnecessary. If you do want to host remotely, Github is a good, free, public choice.

Steve Johnson
OK, so unlike SVN, I will have a Git repository for EACH project?In SVN, I usually have a repository somewhere away from my projects, and then I check in all my projects into that repository.
alamodey
That’s exactly the way it is, alamodey.
Bombe
one repository for one project is the way to use distributed version control system (of which Git is an example)
Jakub Narębski