Monthly Archives: October 2012

Git: How to create a new Repository

Repositories in Git are stored on your local file system right alongside the code they track.You create a repository by typing git init in the directory that you want to start tracking files in.

There are two repositories in Git to collaborate with others: a private one and a public one. Private repository, is where you do all your work. It’s the repository with the working tree.

This two-tier system gives the ability to track local experimental changes while only sharing changes via your public repository that are ready for others to work with.

git init creates a .git directory in your current directory and initializes the Git repository inside that. Once the repository is initialized, we need to add (using git add) and commit (using git commit) the files in the repository.

With an initialized repository, you have a working tree that you can interact with. Working tree is the latest copy of the repository.

Create a repository.
prompt> mkdir test-repository
prompt> cd test-repository
prompt> git init

Add some files in the test-repository folder. To add and commit the files in the repository, use the following commands.

prompt> git add .
prompt> git commit -m “some commit message”

That’s it, with this commands, you have created a new repository and added few files in it.

In the next post on Git, I will discuss about cloning an existing repository into local machine.