GIT Ready
introduction to git and github
Day 1
Who am I ?
● Mosaab Ehab elsayed
● 3rd year student at faculty of engineering
● CSED
● python Web developer with django
● web circle member at CATReloaded
● marketer at IEEEMansB
● good learner seek to be the teacher
Sad Story ….
Version control
also known as revision control
or source control,
is the management of changes to
documents, computer programs,
large web sites, and other
collections of information.
https://goo.gl/e43hnH
Version control Systems
Version control systems are a
category of software tools that help
a software team manage changes to
source code over time.
Version control software
keeps track of every modification to
the code in a special kind of
database.
https://goo.gl/xEkRsa
Version control examples
Any
Editor
use
offline
manual
saving
Any
Editor
use
offline
manual
saving
Manual Saving yes yes yes
Any
Editor
use
offline
manual
saving
Manual Saving yes yes yes
Dropbox yes no no
Any
Editor
use
offline
manual
saving
Manual Saving yes yes yes
Dropbox yes no no
Google Docs no no no
Any
Editor
use
offline
manual
saving
Manual Saving yes yes yes
Dropbox yes no no
Google Docs no no no
Wikipedia no no yes
Version control Systems
● CVS
● SVN
● Mercurial (hg)
● Git
GIT
a version control system for tracking
changes in computer files and
coordinating work on those files
among multiple people. It is primarily
used for source code management in
software development,but it can be
used to keep track of changes in any
set of files
https://goo.gl/xEkRsa
Any
Editor
use
offline
manual
saving
Manual Saving yes yes yes
Dropbox yes no no
Google Docs no no no
Wikipedia no no yes
Git yes yes yes
Installing Git
Windows
Ubuntu
$ sudo apt-get update
$ sudo apt-get install git
Configure your environment
Username and Email
$ git config --global user.name “your name”
$ git config --global user.email “your email”
Commits
https://goo.gl/Pivmfx
commit with multiple files
index.html
commit with multiple files
index.html
game.js
commit with multiple files
index.html
game.js
main.css
commit with multiple files
index.html
game.js
main.css
index.html
commit with multiple files
index.html
game.js
main.css
index.html index.html
commit with multiple files
index.html
game.js
main.css
index.html index.html index.html
commit with multiple files
index.html
game.js
main.css
index.html index.html index.html
game.js
main.css
game.js
main.css
game.js
main.css
commit with multiple files
index.html
game.js
main.css
index.html index.html index.html
game.js
main.css
game.js
main.css
game.js
main.css
commit
What makes a repo a repo ?
GUI Vs Command line
https://goo.gl/HqxcVP
Initialize your first repo ...
Initialization
$ git init
git commit -m “add my first commit”
our first commit
$ git add “file name”
$ git commit -m “your message”
Staging area
Working directory
index.html
game.js
main.css
Working directory
index.html
game.js
main.css
Working directory Repository
index.html
game.js
main.css
Working directory
index.html
game.js
main.css
Repository
Commit
Commit
Commit
index.html
game.js
main.css
Working directory Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
index.html
game.js
main.css
Working directory
index.html
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
git add “file”
index.html
game.js
main.css
Working directory
index.html
game.js
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
git add “file”
index.html
game.js
main.css
Working directory
index.html
game.js
main.css
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
git add “file”
index.html
game.js
main.css
Working directory
index.html
game.js
main.css
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
git add “file” git commit
Display your commits
Display commits
$ git log
$ git log --pretty=oneline
Step back
Step back
$ git reset --hard
or
$ git checkout <commit_id>
git reset
Discard any changes in
either the working directory
or the staging area
index.html
game.js
main.css
Working directory
index.html
game.js
main.css
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
git reset --hard
Branch your master
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: ,
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: ,
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: ,
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: ,
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: ,
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: ,
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
commit: .
author : ..
parent : ..
size: ….
Master
Branching
$ git branch <branch_name>
move to the new branch
$ git checkout <branch_name>
two steps in one
$ git branch <branch_name>
+
$ git checkout <branch_name>
=
$ git checkout -b <branch_name>
display your paths
$ git log --graph --oneline <branch_name> <another_branch>
Merge some branches
display your paths
$ git merge <branch_name> <other_branch>
$ git commit -m “merge branches”
delete branch
$ git branch -d <branch_name>
solve the conflicts between branches
Show your diffs
show your difs
$ git diff
$ git diff <id1> <id2>
$ git diff --staged
index.html
game.js
main.css
Working
directory
index.html
game.js
main.css
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
index.html
game.js
main.css
Working
directory
index.html
game.js
main.css
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
git diff
index.html
game.js
main.css
Working
directory
index.html
game.js
main.css
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
git diff
git diff <id> <id>
index.html
game.js
main.css
Working
directory
index.html
game.js
main.css
Staging Area
index.html
game.js
main.css
Repository
Commit
Commit
Commit
git diff git diff --staged
git diff <id> <id>
Git some help
Git some help
$ git help
$ git help <aspect>
Any questions ?
Thank you :”)
see you soon :”D

Git session day 1