SlideShare a Scribd company logo
GIT >> Version Control System
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Version Control System - VCS
Version control is a system that records changes to a file or set of files over time so that you can recall
specific versions later.
▸ It allows you to revert selected files back to a previous state, revert the entire project back to a
previous state, compare changes over time, see who last modified something that might be causing a
problem, who introduced an issue and when, and more.
▸ Using a VCS also generally means that if you screw things up or lose files, you can easily recover.
2
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Local VCS - LVCS
3
Local VCS maintains a simple database that
records all the changes to files under revision
control.
It keeps patch sets (i.e. the difference
between files) in a special format on disk; it
can then re-create what any file looked like at
any point in time by adding up all the patches.
Problem >>
How to collaborate with other developers?
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Centralized VCS - CVCS
Centralized Version Control Systems
(CVCSs) have a single server that
contains all the versioned files, and a
number of clients that check out files
from that central place.
Problem >>
Centralized server is a single point of
failure.
4
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Distributed VCS - DVCS
In a Distributed Version Control Systems (DVCSs)
clients don’t just check out the latest snapshot of the
files; rather, they fully mirror the repository, including
its full history.
if any server dies, and these systems were
collaborating via that server, any of the client
repositories can be copied back up to the server to
restore it. Every clone is really a full backup of all the
data.
5
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
DVCS >> GIT
▸ Git is a distributed version-control system for tracking changes in source code during software
development.
▸ It is designed for coordinating work among programmers, but it can be used to track changes in any
set of files.
▸ It was created by Linux Development Community (in particular, Linus Torvalds) in 2005 for
development of the Linux kernel when the relationship between the community and the BitKeeper
company broke down.
▸ Git naming:
▹ In British slang, unpleasant person
▹ Global information tracker
▹ Goddamn idiotic truckload of sh*t
6
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT
▸ GIT thinks of its data more like a series of snapshots of a miniature filesystem.
▸ With Git, every time you commit, or save the state of your project, Git basically takes a picture of what
all your files look like at that moment and stores a reference to that snapshot.
▸ To be efficient, if files have not changed, Git doesn’t store the file again, just a link to the previous
identical file it has already stored.
7
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT >> File States
▸ Each file in the working directory can be in 2 states:
▹ Tracked – files that were in the last snapshot.
▹ Untracked – everything else, not in the last snapshot and not in the staging area.
▸ Tracked file states:
▹ Unmodified/Committed – data is safely stored in the local database.
▹ Modified – you have changed the file but have not committed it to your database yet.
▹ Staged – you have marked a modified file in its current version to go into your next commit snapshot.
8
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT >> Stage and Commit Process
▸ Staging the files computes the checksum for each one, stores that version of
the file in the Git repository and adds that checksum to the staging area.
▸ During git commit, git checksums each subdirectory and stores them as a tree
object in the Git repository.
▸ Git then creates a commit object containing metadata and pointer to the
project tree.
9
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT >> Multiple Commits Process
▸ The scenario of multiple commits.
▸ Each new commit stores a pointer to the commit that came immediately before it.
10
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
11
GIT Command Line
- only place you can run all Git commands
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> First-time Setup
12
▸ Version check: $ git --version
▸ Configuration scope:
▹ --system : values applied to every user on the system and all their repositories.
▹ --global : values specific personally to you and affects all the repositories you work with.
▹ --local : values specific to that single repository you are currently using.
▸ Get/Set Configuration variables :
▹ To view all the settings: $ git config --list
▹ To view all the settings with file path: $ git config --list --show-origin
▹ To check a specific variable value: $ git config <key>
▹ To set a specific variable value: $ git config --global <key> <value>
▸ First time setup:
$ git config --global user.name “username”
$ git config -- global user.email “useremail@gmail.com”
cause every git commit uses your name and email
▸ Getting help: $ git <verb> --help
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Getting a GIT Repository
13
▸ Initialize an existing local directory:
Go within that directory and run - $ git init
▸ Clone an existing remote repository:
To clone the remote repository run - $ git clone <url>
To clone the remote repository into your directory run - $ git clone <url> <new-directory-name>
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Creating a GIT Repository
14
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Check/Add/Remove Remote Repository
15
▸ To show all the remote repositories you have configured
$ git remote –v
▸ To add new remote repositories
$ git remote add <shortname> <url>
git clone command implicitly adds the remote for you
▸ To remove remote repository
$ git remote remove <shortname>
▸ To rename remote repository
$ git remote rename <old-shortname> <new-shortname>
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Fetch/Pull/Push Information
16
▸ To fetch
$ git fetch <remote>
This command only downloads the data to your local repository - it doesn’t automatically merge it.
▸ To pull
$ git pull <remote> <branch>
If your current branch(master) is set up to track a remote branch(remote master), then this command
automatically fetch and then merge that remote branch into your current branch.
▸ To push (pull/fetch before push)
$ git push <remote> <branch>
▸ Inspecting a remote,
$ git remote show <remote>
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> How git fetch Works
17
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> How git fetch Works
18
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Recording Repository Changes
19
▸ To get the status of the files
$ git status
▸ To track new file/stage a file
$ git add <file-path>
To add changes from all the tracked and untracked files
$ git add -A
▸ To commit your staged changes (commit records the snapshot you set up in your staging area)
$ git commit –m <commit-message>
To skip the staging area and commit every tracked files(auto staged)
$ git commit –a –m <commit-message>
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Ignoring Specific Files
20
▸ Create a file named .gitignore and
list the file names/patterns that you don’t want GIT to automatically add/even show you as being
untracked.
For example,
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
*.[oa] to ignore any files ending with .o or, .a
!lib.a to track lib.a file even though you are ignoring .a files
/TODO to ignore TODO file in the current directory, not subdirectory
build/ to ignore all files in any directory named build
doc/*.txt to ignore doc/notes.txt file, bit not doc/server/arch.txt, i.e. not within
subdirectory
doc/**/*.pdf To ignore all .pdf files in the doc/ directory and its subdirectory
GIT CLI >> Viewing the Changes
21
▸ To see what you’ve changed but not yet staged (diff. between staged and modified files)
$ git diff
▸ To see what you’ve staged that will go into the next commit (diff. between staged and committed files)
$ git diff --cached
▸ To rename a file in GIT
$ git mv <file_from> <file_to>
▸ To make a tracked file untracked
$ git rm --cached <file-name>
To remove a file from your working directory
$ git rm <file-name>
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Commit History
22
▸ To list all the commits made in the repository in reverse chronological order,
$ git log
▸ To see some abbreviated stats for each commit
$ git log --stat
▸ To see the last 3 commit history
$ git log -3
▸ To see the difference introduced in each commit,
$ git log -p -2
▸ To show each commit in one line
$ git log --oneline
▸ To see the branch and graph history in the form of a graph
$ git log --pretty=format:”%h %s” --graph
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> git log Options
23
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
-<n> Show only the last n commits
--since, --after Limit commits to those made after the specified date
--until, --before Limit the commits to those made before the specified date
--author Only show commits in which the author entry matches the specified string
--committer Only show commits in which the committer entry matches the specified string
--grep Only show commits with a commit message containing the string
-S Only show commits adding or removing code matching the string
GIT CLI >> git log Options
24
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
-p Show the patch introduced in each commit
--stat Show statistics for files modified in each commit
--pretty Show commits in an alternate format. Oneline/short/full/fuller/format
--oneline Shorthand for --pretty=oneline --abbrev-commit
--graph Display an ASCII graph of the branch and merge history beside the log output
%H Commit hash %an, %ae, %ad Author name, email and date
%h Abbreviated commit hash %cn, %ce, %cd Committer name, email and date
%P Parent hashes %s Subject
%p Abbreviated parent hashes
GIT CLI >> Undoing Things
25
▸ To redo the last commit
$ git commit --amend -m “new commit message”
or
$ git commit –amend
▸ To unstage a staged file
$ git reset HEAD <file-name>
▸ To unmodify a modified file
$ git checkout -- <file-name>
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Branching
26
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
▸ To list all the current branches
$ git branch
The * pointed branch indicates the branch currently HEAD points to
▸ To get the list of merged branches
$ git branch –merged
▸ To get the list of unmerged branches
$ git branch –no-merged
▸ To create a new branch
$ git branch <branch-name>
▸ To switch to new branch
$ git checkout <branch-name>
▸ To remove an already merged branch
$ git branch –d <branch-name>
▸ To remove an unmerged branch
$ git branch –D <branch-name>
GIT CLI >> Branching >> initial local repository
27
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Branching >> creating a new branch
28
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
$ git branch <branch-name>
GIT CLI >> Branching >> switching to a new branch
29
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
$ git checkout <branch-name>
GIT CLI >> Branching >> staging & committing in the new branch
30
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
$ git commit –a –m “commit message”
GIT CLI >> Branching >> switching back to master branch
31
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
$ git checkout master
GIT CLI >> Branching >> staging and committing in master branch
32
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
$ git commit –a –m “commit message”
GIT CLI >> Branching >> example-step 1
33
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >> Branching >> example-step 2
34
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Creating a new branch and switching to that branch
$ git checkout -b iss53
or,
$ git branch iss53
$ git checkout iss53
GIT CLI >> Branching >> example-step 3
35
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Committing in that new branch
$ git commit -a –m “commit message”
GIT CLI >> Branching >> example-step 4
36
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Switching back to master, creating new branch hotfix,
switching to that branch and performing a new commit
there
$ git checkout master
$ git checkout hotfix
$ git branch hotfix
$ git commit -a –m “commit message”
GIT CLI >> Branching >> example-step 5
37
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Switching back to branch master and merging with the hotfix branch
$ git checkout master
$ git merge hotfix
GIT CLI >> Branching >> example-step 6
38
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Deleting the hotfix branch, switching to iss53 branch and performing new commit there
$ git branch -d hotfix
$ git checkout iss53
$ git commit –a –m “commit message”
GIT CLI >> Branching >> example-step 7
39
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Going back to master branch
$ git checkout master
GIT CLI >> Branching >> example-step 8
40
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
Merging the master branch with iss53 branch
$ git merge iss53
If conflict occurs, then open and edit the conflicted file
remove the <<<<<<<, =======, >>>>>>> symbols, perform necessary
changes, finally stage and commit the changes
GIT CLI >> Revision Selection
41
▸ To show the details of a specific commit
$ git show <SHA-1 hash value of that commit>
▸ To see the log of where your HEAD and branch references have been for the last few months
$ git reflog
▸ To refer to the older commits from the current HEAD position
$ git show HEAD@{5}
▸ To show the first parent of a specific commit
$ git show HEAD^
To show the second parent(meaning other branch parent) of a specific commit
$ git show HEAD^2
▸ To show the first parent of a first parent
$ git show HEAD~2
▸ Difference between the second branch commits with first branch commits
$ git log br1..br2
▸ Difference between both of the branch commits
$ git log br1…br2
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>Temporarily saving changes at a Branch
42
To switch branches for a bit to work on something else. The problem is, you don’t want to do a commit of
half-done work just so you can get back to this point later. The answer to this issue is the git stash
command.
Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged
changes — and saves it on a stack of unfinished changes that you can reapply at any time (even on a
different branch).
 To save the current work
$ git stash push
 To check all the stashes
$git stash list
 To apply any certain stash changes to the current branch file
$ git stash apply
or, $ git stash apply stash@{2}
 To delete a saved stash from the stack
$ git stash drop stash@{1}
 To apply the stash changes and also delete from the stack at the same time
$ git stash pop stash@{1}
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
43
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
44
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
45
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
46
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
47
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
48
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
49
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
50
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
51
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
GIT CLI >>The Role of Reset
52
Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
53
THANKS!
Any questions?
You can find me at imam@cse.uiu.ac.bd

More Related Content

What's hot

Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
Sébastien Saunier
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Panagiotis Papadopoulos
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
Dilum Navanjana
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
Craig Smith
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
Sourabh Sahu
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Github basics
Github basicsGithub basics
Github basics
Radoslav Georgiev
 
Version control system
Version control systemVersion control system
Version control system
Andrew Liu
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Lukas Fittl
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
Git
GitGit
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
Luigi De Russis
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
Omar Fathy
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
PravallikaTammisetty
 

What's hot (20)

Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Github basics
Github basicsGithub basics
Github basics
 
Version control system
Version control systemVersion control system
Version control system
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Git
GitGit
Git
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 

Similar to GIT | Distributed Version Control System

Git and Github
Git and GithubGit and Github
Git and Github
Teodora Ahkozidou
 
Git and github
Git and githubGit and github
Git and github
Teodora Ahkozidou
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
git2.ppt
git2.pptgit2.ppt
Git 101
Git 101Git 101
Git 101
jayrparro
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Git
GitGit
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)
Mizan Riqzia
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
ssusered2ec2
 
Git
GitGit
SVN 2 Git
SVN 2 GitSVN 2 Git
SVN 2 Git
Marco De Stefano
 
Git
GitGit
Presentation on Repository Control System
Presentation on Repository Control SystemPresentation on Repository Control System
Presentation on Repository Control System
Md. Mujahid Islam
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
Wildan Maulana
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
AbelPhilipJoseph
 
GDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptxGDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptx
ChitreshGyanani1
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GIT
Zeeshan Khan
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin Ren
 

Similar to GIT | Distributed Version Control System (20)

Git and Github
Git and GithubGit and Github
Git and Github
 
Git and github
Git and githubGit and github
Git and github
 
Git introduction
Git introductionGit introduction
Git introduction
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Git 101
Git 101Git 101
Git 101
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git
GitGit
Git
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)Nge-GIT (Belajar Git Bareng)
Nge-GIT (Belajar Git Bareng)
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Git
GitGit
Git
 
SVN 2 Git
SVN 2 GitSVN 2 Git
SVN 2 Git
 
Git
GitGit
Git
 
Presentation on Repository Control System
Presentation on Repository Control SystemPresentation on Repository Control System
Presentation on Repository Control System
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting Started
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
GDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptxGDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptx
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GIT
 
Git github
Git githubGit github
Git github
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 

More from Mohammad Imam Hossain

DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6
Mohammad Imam Hossain
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic Programming
Mohammad Imam Hossain
 
DS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MSTDS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MST
Mohammad Imam Hossain
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path Search
Mohammad Imam Hossain
 
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3
Mohammad Imam Hossain
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and Conquer
Mohammad Imam Hossain
 
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2
Mohammad Imam Hossain
 
DS & Algo 2 - Recursion
DS & Algo 2 - RecursionDS & Algo 2 - Recursion
DS & Algo 2 - Recursion
Mohammad Imam Hossain
 
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1
Mohammad Imam Hossain
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL Introduction
Mohammad Imam Hossain
 
DBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMSDBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMS
Mohammad Imam Hossain
 
DBMS 10 | Database Transactions
DBMS 10 | Database TransactionsDBMS 10 | Database Transactions
DBMS 10 | Database Transactions
Mohammad Imam Hossain
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
Mohammad Imam Hossain
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
Mohammad Imam Hossain
 
DBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageDBMS 7 | Relational Query Language
DBMS 7 | Relational Query Language
Mohammad Imam Hossain
 
DBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsDBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML Commands
Mohammad Imam Hossain
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR Schema
Mohammad Imam Hossain
 
TOC 10 | Turing Machine
TOC 10 | Turing MachineTOC 10 | Turing Machine
TOC 10 | Turing Machine
Mohammad Imam Hossain
 
TOC 9 | Pushdown Automata
TOC 9 | Pushdown AutomataTOC 9 | Pushdown Automata
TOC 9 | Pushdown Automata
Mohammad Imam Hossain
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity Check
Mohammad Imam Hossain
 

More from Mohammad Imam Hossain (20)

DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic Programming
 
DS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MSTDS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MST
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path Search
 
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and Conquer
 
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2
 
DS & Algo 2 - Recursion
DS & Algo 2 - RecursionDS & Algo 2 - Recursion
DS & Algo 2 - Recursion
 
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL Introduction
 
DBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMSDBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMS
 
DBMS 10 | Database Transactions
DBMS 10 | Database TransactionsDBMS 10 | Database Transactions
DBMS 10 | Database Transactions
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
 
DBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageDBMS 7 | Relational Query Language
DBMS 7 | Relational Query Language
 
DBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsDBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML Commands
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR Schema
 
TOC 10 | Turing Machine
TOC 10 | Turing MachineTOC 10 | Turing Machine
TOC 10 | Turing Machine
 
TOC 9 | Pushdown Automata
TOC 9 | Pushdown AutomataTOC 9 | Pushdown Automata
TOC 9 | Pushdown Automata
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity Check
 

Recently uploaded

How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17
Celine George
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
JomonJoseph58
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 

Recently uploaded (20)

How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 

GIT | Distributed Version Control System

  • 1. GIT >> Version Control System Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 2. Version Control System - VCS Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. ▸ It allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. ▸ Using a VCS also generally means that if you screw things up or lose files, you can easily recover. 2 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 3. Local VCS - LVCS 3 Local VCS maintains a simple database that records all the changes to files under revision control. It keeps patch sets (i.e. the difference between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches. Problem >> How to collaborate with other developers? Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 4. Centralized VCS - CVCS Centralized Version Control Systems (CVCSs) have a single server that contains all the versioned files, and a number of clients that check out files from that central place. Problem >> Centralized server is a single point of failure. 4 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 5. Distributed VCS - DVCS In a Distributed Version Control Systems (DVCSs) clients don’t just check out the latest snapshot of the files; rather, they fully mirror the repository, including its full history. if any server dies, and these systems were collaborating via that server, any of the client repositories can be copied back up to the server to restore it. Every clone is really a full backup of all the data. 5 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 6. DVCS >> GIT ▸ Git is a distributed version-control system for tracking changes in source code during software development. ▸ It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. ▸ It was created by Linux Development Community (in particular, Linus Torvalds) in 2005 for development of the Linux kernel when the relationship between the community and the BitKeeper company broke down. ▸ Git naming: ▹ In British slang, unpleasant person ▹ Global information tracker ▹ Goddamn idiotic truckload of sh*t 6 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 7. GIT ▸ GIT thinks of its data more like a series of snapshots of a miniature filesystem. ▸ With Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. ▸ To be efficient, if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored. 7 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 8. GIT >> File States ▸ Each file in the working directory can be in 2 states: ▹ Tracked – files that were in the last snapshot. ▹ Untracked – everything else, not in the last snapshot and not in the staging area. ▸ Tracked file states: ▹ Unmodified/Committed – data is safely stored in the local database. ▹ Modified – you have changed the file but have not committed it to your database yet. ▹ Staged – you have marked a modified file in its current version to go into your next commit snapshot. 8 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 9. GIT >> Stage and Commit Process ▸ Staging the files computes the checksum for each one, stores that version of the file in the Git repository and adds that checksum to the staging area. ▸ During git commit, git checksums each subdirectory and stores them as a tree object in the Git repository. ▸ Git then creates a commit object containing metadata and pointer to the project tree. 9 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 10. GIT >> Multiple Commits Process ▸ The scenario of multiple commits. ▸ Each new commit stores a pointer to the commit that came immediately before it. 10 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 11. 11 GIT Command Line - only place you can run all Git commands Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 12. GIT CLI >> First-time Setup 12 ▸ Version check: $ git --version ▸ Configuration scope: ▹ --system : values applied to every user on the system and all their repositories. ▹ --global : values specific personally to you and affects all the repositories you work with. ▹ --local : values specific to that single repository you are currently using. ▸ Get/Set Configuration variables : ▹ To view all the settings: $ git config --list ▹ To view all the settings with file path: $ git config --list --show-origin ▹ To check a specific variable value: $ git config <key> ▹ To set a specific variable value: $ git config --global <key> <value> ▸ First time setup: $ git config --global user.name “username” $ git config -- global user.email “useremail@gmail.com” cause every git commit uses your name and email ▸ Getting help: $ git <verb> --help Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 13. GIT CLI >> Getting a GIT Repository 13 ▸ Initialize an existing local directory: Go within that directory and run - $ git init ▸ Clone an existing remote repository: To clone the remote repository run - $ git clone <url> To clone the remote repository into your directory run - $ git clone <url> <new-directory-name> Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 14. GIT CLI >> Creating a GIT Repository 14 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 15. GIT CLI >> Check/Add/Remove Remote Repository 15 ▸ To show all the remote repositories you have configured $ git remote –v ▸ To add new remote repositories $ git remote add <shortname> <url> git clone command implicitly adds the remote for you ▸ To remove remote repository $ git remote remove <shortname> ▸ To rename remote repository $ git remote rename <old-shortname> <new-shortname> Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 16. GIT CLI >> Fetch/Pull/Push Information 16 ▸ To fetch $ git fetch <remote> This command only downloads the data to your local repository - it doesn’t automatically merge it. ▸ To pull $ git pull <remote> <branch> If your current branch(master) is set up to track a remote branch(remote master), then this command automatically fetch and then merge that remote branch into your current branch. ▸ To push (pull/fetch before push) $ git push <remote> <branch> ▸ Inspecting a remote, $ git remote show <remote> Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 17. GIT CLI >> How git fetch Works 17 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 18. GIT CLI >> How git fetch Works 18 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 19. GIT CLI >> Recording Repository Changes 19 ▸ To get the status of the files $ git status ▸ To track new file/stage a file $ git add <file-path> To add changes from all the tracked and untracked files $ git add -A ▸ To commit your staged changes (commit records the snapshot you set up in your staging area) $ git commit –m <commit-message> To skip the staging area and commit every tracked files(auto staged) $ git commit –a –m <commit-message> Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 20. GIT CLI >> Ignoring Specific Files 20 ▸ Create a file named .gitignore and list the file names/patterns that you don’t want GIT to automatically add/even show you as being untracked. For example, Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU *.[oa] to ignore any files ending with .o or, .a !lib.a to track lib.a file even though you are ignoring .a files /TODO to ignore TODO file in the current directory, not subdirectory build/ to ignore all files in any directory named build doc/*.txt to ignore doc/notes.txt file, bit not doc/server/arch.txt, i.e. not within subdirectory doc/**/*.pdf To ignore all .pdf files in the doc/ directory and its subdirectory
  • 21. GIT CLI >> Viewing the Changes 21 ▸ To see what you’ve changed but not yet staged (diff. between staged and modified files) $ git diff ▸ To see what you’ve staged that will go into the next commit (diff. between staged and committed files) $ git diff --cached ▸ To rename a file in GIT $ git mv <file_from> <file_to> ▸ To make a tracked file untracked $ git rm --cached <file-name> To remove a file from your working directory $ git rm <file-name> Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 22. GIT CLI >> Commit History 22 ▸ To list all the commits made in the repository in reverse chronological order, $ git log ▸ To see some abbreviated stats for each commit $ git log --stat ▸ To see the last 3 commit history $ git log -3 ▸ To see the difference introduced in each commit, $ git log -p -2 ▸ To show each commit in one line $ git log --oneline ▸ To see the branch and graph history in the form of a graph $ git log --pretty=format:”%h %s” --graph Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 23. GIT CLI >> git log Options 23 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU -<n> Show only the last n commits --since, --after Limit commits to those made after the specified date --until, --before Limit the commits to those made before the specified date --author Only show commits in which the author entry matches the specified string --committer Only show commits in which the committer entry matches the specified string --grep Only show commits with a commit message containing the string -S Only show commits adding or removing code matching the string
  • 24. GIT CLI >> git log Options 24 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU -p Show the patch introduced in each commit --stat Show statistics for files modified in each commit --pretty Show commits in an alternate format. Oneline/short/full/fuller/format --oneline Shorthand for --pretty=oneline --abbrev-commit --graph Display an ASCII graph of the branch and merge history beside the log output %H Commit hash %an, %ae, %ad Author name, email and date %h Abbreviated commit hash %cn, %ce, %cd Committer name, email and date %P Parent hashes %s Subject %p Abbreviated parent hashes
  • 25. GIT CLI >> Undoing Things 25 ▸ To redo the last commit $ git commit --amend -m “new commit message” or $ git commit –amend ▸ To unstage a staged file $ git reset HEAD <file-name> ▸ To unmodify a modified file $ git checkout -- <file-name> Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 26. GIT CLI >> Branching 26 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU ▸ To list all the current branches $ git branch The * pointed branch indicates the branch currently HEAD points to ▸ To get the list of merged branches $ git branch –merged ▸ To get the list of unmerged branches $ git branch –no-merged ▸ To create a new branch $ git branch <branch-name> ▸ To switch to new branch $ git checkout <branch-name> ▸ To remove an already merged branch $ git branch –d <branch-name> ▸ To remove an unmerged branch $ git branch –D <branch-name>
  • 27. GIT CLI >> Branching >> initial local repository 27 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 28. GIT CLI >> Branching >> creating a new branch 28 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU $ git branch <branch-name>
  • 29. GIT CLI >> Branching >> switching to a new branch 29 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU $ git checkout <branch-name>
  • 30. GIT CLI >> Branching >> staging & committing in the new branch 30 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU $ git commit –a –m “commit message”
  • 31. GIT CLI >> Branching >> switching back to master branch 31 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU $ git checkout master
  • 32. GIT CLI >> Branching >> staging and committing in master branch 32 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU $ git commit –a –m “commit message”
  • 33. GIT CLI >> Branching >> example-step 1 33 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 34. GIT CLI >> Branching >> example-step 2 34 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU Creating a new branch and switching to that branch $ git checkout -b iss53 or, $ git branch iss53 $ git checkout iss53
  • 35. GIT CLI >> Branching >> example-step 3 35 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU Committing in that new branch $ git commit -a –m “commit message”
  • 36. GIT CLI >> Branching >> example-step 4 36 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU Switching back to master, creating new branch hotfix, switching to that branch and performing a new commit there $ git checkout master $ git checkout hotfix $ git branch hotfix $ git commit -a –m “commit message”
  • 37. GIT CLI >> Branching >> example-step 5 37 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU Switching back to branch master and merging with the hotfix branch $ git checkout master $ git merge hotfix
  • 38. GIT CLI >> Branching >> example-step 6 38 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU Deleting the hotfix branch, switching to iss53 branch and performing new commit there $ git branch -d hotfix $ git checkout iss53 $ git commit –a –m “commit message”
  • 39. GIT CLI >> Branching >> example-step 7 39 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU Going back to master branch $ git checkout master
  • 40. GIT CLI >> Branching >> example-step 8 40 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU Merging the master branch with iss53 branch $ git merge iss53 If conflict occurs, then open and edit the conflicted file remove the <<<<<<<, =======, >>>>>>> symbols, perform necessary changes, finally stage and commit the changes
  • 41. GIT CLI >> Revision Selection 41 ▸ To show the details of a specific commit $ git show <SHA-1 hash value of that commit> ▸ To see the log of where your HEAD and branch references have been for the last few months $ git reflog ▸ To refer to the older commits from the current HEAD position $ git show HEAD@{5} ▸ To show the first parent of a specific commit $ git show HEAD^ To show the second parent(meaning other branch parent) of a specific commit $ git show HEAD^2 ▸ To show the first parent of a first parent $ git show HEAD~2 ▸ Difference between the second branch commits with first branch commits $ git log br1..br2 ▸ Difference between both of the branch commits $ git log br1…br2 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 42. GIT CLI >>Temporarily saving changes at a Branch 42 To switch branches for a bit to work on something else. The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later. The answer to this issue is the git stash command. Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch).  To save the current work $ git stash push  To check all the stashes $git stash list  To apply any certain stash changes to the current branch file $ git stash apply or, $ git stash apply stash@{2}  To delete a saved stash from the stack $ git stash drop stash@{1}  To apply the stash changes and also delete from the stack at the same time $ git stash pop stash@{1} Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 43. GIT CLI >>The Role of Reset 43 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 44. GIT CLI >>The Role of Reset 44 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 45. GIT CLI >>The Role of Reset 45 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 46. GIT CLI >>The Role of Reset 46 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 47. GIT CLI >>The Role of Reset 47 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 48. GIT CLI >>The Role of Reset 48 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 49. GIT CLI >>The Role of Reset 49 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 50. GIT CLI >>The Role of Reset 50 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 51. GIT CLI >>The Role of Reset 51 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 52. GIT CLI >>The Role of Reset 52 Mohammad Imam Hossain | Lecturer, dept. of CSE | UIU
  • 53. 53 THANKS! Any questions? You can find me at imam@cse.uiu.ac.bd