GIT for your code maintenance

want to set a local GIT repository and have everything from scratch

Why this document:
After having setup so many times the git repository I keep forgetting and I am surprised that I have not cretaed such docuemnt earlier so it not late.

lets start:

setting up git respository :

method 1
1. remote repository

 git init --bare   (create a empty remote repo)

2. local working repository

 git init (this creates a .git repo file in your local working directory)

create your source files . ex: hello.c


 git add hello.c

[ it is better to setup your git config file after this as you might have to change your editor for commiting ]


 git commit -a

add your commit message and save your commit
your commit can look like below:


 preetam@preetam-desktop:/media/drive1/src$ git log
 commit d13afd0101ecaa69f90525f9d884e3e0561c90e3
 Author: Preetam<>
 Date:   Thu Jan 29 20:48:16 2015 +0530

initial version

added initial version of the project code



git clone --bare <remote repository>
git remote add origin <remote repository>
git push --set-upstream origin master

with output as
Counting objects: 12, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (12/12), 6.90 KiB, done.
Total 12 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (12/12), done.
To <remote repositroy>
* [new branch]      master -> master
Branch master set up to track remote branch master from origin.

$ git config –global “preetam”
$ git config –global

you file will look like this
ui = auto
name = Preetam M N
email =

using the sample git-config file you could add below to make vim and vimdiff as your default editor and difftool

editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
tool = vimdiff
prompt = false
reference :

original data
good usage material
setting up your git-config
sample git-config file

Disclaimer : All information copywrite is held with their respective owner, this is just an attempt to collate that data and doesnot hold any responsibility of the ownership.


About preetammn

engineer trying to figure out the world, people and machines.
This entry was posted in git. Bookmark the permalink.

One Response to GIT for your code maintenance

  1. Pingback: converting local git repository to remote git repository within LAN | Mystic World

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 )

Google+ photo

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


Connecting to %s