Overview & Problem definition

  • Project Backup strategy
    • Disk crash
    • Professional Work Archiving

      final, final1, final2, … etc.

      What is the working file ??

  • Team work collaboration
    • Work on same source
    • Auto merging work
  • Record all changes
  • View all history of the project

Git Version Control System

  • The most popular version control system
  • Supports parallel simultaneous development
  • Handle huge number of users
  • Branch development and easy merging
  • Others: SVN , Mercurial

Getting Started

  • Installation
    • For linux
        sudo apt-get install git
      
    • For windows install from here

Open the bash

To open bash click git bash here

Git and github

  • create an account on github
  • github : remote server
  • git : local development
  • Allow code sharing and team contribution

The work flow

Basic Illustration

Git cycle

  • Configuration : one time after installation
git config --global user.email "example@mail.com"
git config --global user.mail "Name"

Create or clone repository

  • Repository is the source code of the project
  • Create empty repository
    git init
    
  • Clone existing one
    git clone URL
    
  • Showing repository status
    git status 
    

Tracking and Commit

  • Tracking file content
    git add filename
    
  • ignore changes
git stash

Commit

  • Recording change in the repository
  • Snapshot of project at this state
  • Records
    • How was the change
    • Who did it and when
    • The purpose of that change
      git commit -m "Your message"
      

Project Monitoring

  • Show history
git log 

git show commitId

Transition between states (commits)

Switch to a certain commit

git checkout commitId

Back to last commit

git checkout master

Publishing and sharing

  • Updating local repository from master branch
git pull origin master 
  • Publishing your commits on master branch
git push origin master
  • Auto-merge is enabled

Branches

  • Separate line of development
  • Used for
    • Parallel development
    • Bug isolation and fix
    • Trying new idea
  • Finally branch is merged or deleted

Branched cont,

  • Create branch
    git checkout -b branch_name
    
  • Show branches
    git show-branch
    
  • Merge branch to master
git checkout master
git merge branch_name

Merge Conflict

  • Merging in case of same line is modified by through commits
  • Example

Resources