SlideShare ist ein Scribd-Unternehmen logo
1 von 53
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

Weitere ähnliche Inhalte

Was ist angesagt?

Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeMd Swawibe Ul Alam
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and GithubSomkiat Puisungnoen
 
git and github
git and githubgit and github
git and githubDarren Oakley
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHubVikram SV
 
Version control system and Git
Version control system and GitVersion control system and Git
Version control system and Gitramubonkuri
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
Introducing GitLab (June 2018)
Introducing GitLab (June 2018)Introducing GitLab (June 2018)
Introducing GitLab (June 2018)Noa Harel
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagramsDilum Navanjana
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction TutorialThomas Rausch
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
Git and git flow
Git and git flowGit and git flow
Git and git flowFran GarcĂ­a
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdfTilton2
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Git github
Git githubGit github
Git githubAnurag Deb
 

Was ist angesagt? (20)

Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
git and github
git and githubgit and github
git and github
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Version control system and Git
Version control system and GitVersion control system and Git
Version control system and Git
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Introducing GitLab (June 2018)
Introducing GitLab (June 2018)Introducing GitLab (June 2018)
Introducing GitLab (June 2018)
 
Git basics
Git basicsGit basics
Git basics
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
Git commands
Git commandsGit commands
Git commands
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git github
Git githubGit github
Git github
 

Ähnlich wie GIT Version Control System Overview

Git 101
Git 101Git 101
Git 101jayrparro
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
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
 
Presentation on Repository Control System
Presentation on Repository Control SystemPresentation on Repository Control System
Presentation on Repository Control SystemMd. Mujahid Islam
 
Git Workshop : Getting Started
Git Workshop : Getting StartedGit Workshop : Getting Started
Git Workshop : Getting StartedWildan Maulana
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxAbelPhilipJoseph
 
GDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptxGDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptxChitreshGyanani1
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GITZeeshan Khan
 

Ähnlich wie GIT Version Control System Overview (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
 
Git
GitGit
Git
 
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
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
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
 

Mehr von 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 6Mohammad Imam Hossain
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingMohammad 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 MSTMohammad 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 SearchMohammad Imam Hossain
 
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3Mohammad Imam Hossain
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerMohammad Imam Hossain
 
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2Mohammad Imam Hossain
 
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1Mohammad 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 IntroductionMohammad Imam Hossain
 
DBMS 10 | Database Transactions
DBMS 10 | Database TransactionsDBMS 10 | Database Transactions
DBMS 10 | Database TransactionsMohammad 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 SchemaMohammad Imam Hossain
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelMohammad Imam Hossain
 
DBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageDBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageMohammad Imam Hossain
 
DBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsDBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsMohammad 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 SchemaMohammad 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 CheckMohammad Imam Hossain
 

Mehr von 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
 

KĂźrzlich hochgeladen

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

KĂźrzlich hochgeladen (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
CĂłdigo Creativo y Arte de Software | Unidad 1
CĂłdigo Creativo y Arte de Software | Unidad 1CĂłdigo Creativo y Arte de Software | Unidad 1
CĂłdigo Creativo y Arte de Software | Unidad 1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

GIT Version Control System Overview

  • 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