How to Create Centralized Local “Git Repository”

Hi friends,

Lets see “How to Create Centralized Local “Git Repository

First we have to install “git-core” on both server and client. here I’m using Fedora, So I’m installing using “yum install”. Ubuntu people may use “apt-get install”

[server] $ sudo yum install git git-core

[client] $ sudo yum install git git-core


[client side]

Go to the project Directory using “cd” command.

$ cd project_directory

$ git init

$ git add .

$git commit -m “First commit”

Assume your project is in the directory ~/project. Now we have to create a clone of that project using “–bare”

$ git clone –bare ~/project project.git

Next, copy project.git to the server where you plan to host the public repository. You can use scp, rsync, or whatever is most convenient.

$ scp -r project.git servername@ipaddress:/path_to_dir

Now we copied the project into the “Server Repository”.That’s All.

Then, When you need to clone (or) pull, Create new directory and go insde of that dire., When we cloned a project from server repo., just start with that cloned project and make modifications and make commits using “$ git commit -m “message” then just use “$ git push” to push the modified project. 🙂

$ mkdir cloned

$ cd cloned

$ git clone servername@ipaddress:/path_to_dir/project


[rajee@localhost pro]$ git clone --bare sample_app/ sample_app.git
Cloning into bare repository sample_app.git...
[rajee@localhost pro]$ scp -r sample_app.git/

[rajee@localhost ~]$ cd cloned/
[rajee@localhost cloned]$ ls
fapp  testdir  testdir.git

[rajee@localhost cloned]$ git clone suresh@
Cloning into sample_app...
suresh@'s password:
remote: Counting objects: 491, done.
remote: Compressing objects: 100% (451/451), done.
remote: Total 491 (delta 210), reused 0 (delta 0)
Receiving objects: 100% (491/491), 214.64 KiB, done.
Resolving deltas: 100% (210/210), done.

[rajee@localhost cloned]$ ls
fapp  sample_app  testdir  testdir.git
[rajee@localhost cloned]$
suresh@'s password:

[rajee@localhost rails_projects]$ cd sample_app
rajee@localhost rails_projects]$ # make modifications
[rajee@localhost rails_projects]$ git push


That’s all.



One thought on “How to Create Centralized Local “Git Repository”

Leave a Reply

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

You are commenting using your 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