An introduction to Git

WHAT IS GIT
-
Distributed (Decentralized)
version control system
-
Each repository independent and has complete version history
-
Offline is the normal case
-
Each clone is a backup
-
most commands local
-
commit, branch, merge, history
-
The Three States
Git has three main states that your files can reside in: modified, staged, and committed:

Repository types
- Git has two repository types: local and remote.
- The local repo is on your own machine, you have direct access to it.
- The remote repo is usually a centralized server.
- The action of send information to the remote repo is called pushing commits.

Branches in a Nutshell
- Branching means you diverge from the main line of development and continue to do work without messing with that main line

How Git stores its data :
Git doesn’t store data as a series of changesets or differences, but instead as a series of snapshots.
Git stores a commit object that contains a pointer to the snapshot of the content you staged.
When you make a commit :

A Brief example :
Creating a new commit :
$ git add README test.rb LICENSE
$ git commit -m 'Initial commit'

Creating two new commits :

If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it.
Where is the master branch :
As you start making commits, you’re given a master branch that points to the last commit you made.

Creating a new branch :
$ git branch testing
How does Git know what branch you’re currently on? It keeps a special pointer called HEAD.

Switching Branches :
$ git checkout testing
This moves HEAD to point to the testing branch :

Adding a new commit on testing Branch :
$ vim test.rb
$ git commit -a -m 'made a change'

Adding a new commit on master Branch :
$ git checkout master
$ vim test.rb
$ git commit -a -m 'made other changes'

LET'S GO TO CODE

Use Case:
"Create a wrapper implementation to Transformer"
Hint: Use Git to do a colaborite work
Git
By Ernesto Chero
Git
- 2