Git – Tutorial (Try it) 1

There is no CVS no subversion.

What is GIT?
1. Version Control System
2. Distributed Version Control System

Where is it used ?
1. Linux kernel
2. Android
3. Xorg and XServer

What do you mean by distributed?

Every dev has full copy, which keeps all history.
No concept of centeral server.

Most operations are local unless we are doing push or pop. So its very fast.

How we can work ?

1. Single Developer :-

each day
LAPTOP ———-> USB|Sever
push

2. Multiple Developer :-

Dev1 ——> Server ——> Dev2
<—–            <—–

So :-

* In Subversion/CVS

forced to use central server
Dev only have copy of current state

* GIT (Distributed)

 work how we want single dev, centeral server, dictation, heirarichal
 All working copies are full repos i.e. contains all history of all repo.

Single developer

  • Create Project
  • Add files
  • Commit changes
  • Push changes

Basic Commands of GIT

git config

Doing Global Settings.

git config --global user.name "anyUserName"
git config --global user.email "emailId"

we can see the above settings as: (Below is the linux command)

gedit .gitconfig

Now lets check how to make git directory i.e. make a directory in we will keep the repo.

Intializing git repo

git init .

To check the status

git status

If you make a file under the current directory and then you run the command

git status

(git will tell you that there is a file but it is not going to keep track of this.)

For tracking

git add <file name>

or

git add . (Will add all the files)
git commit <file name>

or

git commit . (will commit all the files)

GIT Vs Subversion
——————-
subversion

repo repersented as a number.
start at 1
then increment it

GIT

each file gets a version number 1.1, 1.2, 1.3
each commit gets a number which is SHA1 hash
guarantees content of Repo
promise that what we put in is what we get out

Lets see more GIT commands:

* Now edit a file and save it and then do


git status

It will twll a file is updated but if we do (git commit) then nothing it shows there is nothing to commit.

Lets Check Why

Before commit we have to first add the file to the staging area, which we can do by


git add <file name>

and at this time we can also rollback the file by * git reset

We can also see the logs by :

git log

What if we want the file to get committed directly without pushing it to the staging area


git commit -A

Now lets check how to push the files to remote repo:

Make one git repo (i.e. the remote repo) by:


git init --bare

Now got to original project directory and add this newly created repo as remote


git remote add <anyName> <pathToTheRemoteRepo>

And now push the project into the remote repo:


git push <remoteRepoName> master

Here master is the name of the branch only needed first time.

Now lets check how to fetch the changes:


git fetch <remote repo name>

and to apply these changes in the working copy


git rebase <remoteRepoName/master>

One comment on “Git – Tutorial (Try it)

  1. Reply kimkardashiangamecheats.com Sep 13,2015 2:22 am

    This is a very good tip especially to those new to
    the blogosphere. Simple but very precise information… Thanks for sharing this one.
    A must read article!

Leave a Reply