Git – Introduction – Part I



Git – Introduction – Part I

1 0


Git-Introduction-Part-I


On Github rcos / Git-Introduction-Part-I

Git

Introduction

Part I

Created by Luis Ibanez / @luisibanez and modifed by Moorthy /@mskmoorthy

Git Introduction by Luis Ibanez(original author) Modified by Moothy is licensed under a Creative Commons Attribution 3.0 Unported License.

Install Git

Instructions Here

Global Configuration

Author Information

git config --global user.name "mskmoorthy"
git config --global user.email mskmoorthy@gmail.com

Global Configuration

Color Preferences

git config --global color.ui "auto"

Check Configuration

git config --global --list

Create Directory

  • Make new directory "exercise01"
  • Change into new directory "exercise01"

Create Directory

mkdir exercise01

cd exercise01

Create Local

Git Repository

  • Initialize local Repository

Create Local

Git Repository

git init

Edit New File

vim README.md

Edit New File

Edit New File

Vim Commands

i
This is a new file
ESC
:wq

Edit New File

Vim Commands

  • i = insert mode
  • ...write something...
  • ESC = command mode
  • :wq = write and quit

What is going on?

ls -l

What is going on?

git status

What is going on?

Add File to

Repository

git add README.md

What is going on?

git status

What is going on?

Commit File

into Repository

git commit

Editor should open

Write Commit Message

It should look like an email

  • First line is the SUBJECT
  • Second line is empty
  • The rest, are paragraphs with the BODY of the email.

Write Commit Message

Git can already answer

  • Who
  • When
  • What
git log

File Status Lifecycle

Courtesy of git-scm Book.

The Three States

Courtesy of git-scm Book.

Go to your Github Page

Create a Repository "Exercise01" under your github account (same name)
 git remote add origin http://github.com/mskmoorthy/Exercise01.git
 git push -u origin

Your Turn !

Changes bring

Happiness!

Modify and Commit the file

  • Edit the file
  • Git add the changes
  • Git commit the changes
  • Git check the log

Branching

Inspect Branches

git branch

Create New Branch

git branch happybranch
git branch
git checkout happybranch
git branch

Move to New Branch

git checkout happybranch

Changes bring

Happiness!

Modify and Commit a file

  • Edit the file
  • Git add the changes
  • Git commit the changes
  • Git check the log

File Lifecycle

vim README.md
git add
git commit
git branch

Merge Branch

git branch
git checkout master
git branch
git merge happybranch

Let's do it Again!

git branch happierbranch
git checkout happierbranch
vim README.md
git add README.md
git commit

Merge Differently

git checkout master
git merge --no-ff happierbranch

Explain the Merge

Inspect Branches

gitk

Your Turn !

Branches bring

Happiness!

Branch and Merge

  • Create new branch
  • Move into new branch
  • Edit and commit file
  • Move to master branch
  • Merge new branch into master

Complete Three Merges!

THE END

BY Luis Ibanez some modifications by Moorthy