Vikas Gupta: Software architect

Git: How to create a new Repository

Posted by Vikas Gupta on October 16, 2012

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: