0%

Git

The best way to learn is trying it. HERE is a interactive website link.

Git is a distributed revision control and source code management system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development.

Installation

1
$ sudo apt-get install git-core

Configure

1
2
$ git config --global user.name [name]
$ git config --global user.email [email]

Create and Initialize Repository

1
2
3
$ mkdir git_folder
$ cd git_folder
$ git init

Clone Repository

1
$ git clone example@git.com:project.git

Making changes

1
$ git add .

This snapshot is now stored in a temporary staging area which Git calls the “index”. You can permanently store the contents of the index in the repository with git commit:

1
$ git commit

This will prompt you for a commit message.
Or just use -m to set commit message directly.

1
$ git commit -m [message]

You’ve now stored the first version of your project in Git.

Viewing project history

At any point you can view the history of your changes using

1
$ git log

Managing branches

A single Git repository can maintain multiple branches of development.
To create a new branch named “experimental”, use

1
$ git branch experimental

If you now run

1
$ git branch

you’ll get a list of all existing branches:

1
2
  experimental
* master

The “experimental” branch is the one you just created, and the “master” branch is a default branch that was created for you automatically. The asterisk marks the branch you are currently on; type

1
$ git checkout experimental

to switch to the experimental branch.

Push and Pull

The Push operation stores data permanently to the Git repository.

1
$ git push origin master

The Pull operation will retrieve the data from repository.

1
$ git pull

Further update to be continued