SlideShare a Scribd company logo
Version control system
What is a Version Control System (VCS)
 a software utility that tracks and manages changes to a file system.
 kind of "database". lets you save changes and take a look over time.
 tracks the addition, deletion, and modification actions applied to files and
directories.
 offers collaborative utilities to share and integrate these file system changes to
other VCS users.
Primary benefits of a VCS
 A complete long-term change history of every file.
 Branching and merging.
 Traceability
Most popular version controls systems
Source : https://www.openhub.net/
VCS’s in Open Source Projects
Centralized vs Distributed
“Tools” to get started with Git
 Git itself. Download from official site https://git-scm.com/downloads
 Git Bash. Convenient Command Prompt (Terminal) for Windows to run Git
commands and Unix commands such as cat, touch etc.
 Git GUI Clients : GitHub Desktop, GitKraken, SmartGit, SourceTree, TortoiseGit.
 Even more GUI clients at https://git-scm.com/downloads/guis
 IDE integrated Git tools and plugins to work with Git. Most IDE’s have built in tools
or plugins to support Git.
Git basic commands
 git init – initializes current directory as Git repository
 git add - adds file(s) to “Staging Area”
 git commit – creates new commit/version.
 git status – shows the working tree (files & directories) status
 git log – list commits
 gitignore – prevent files and directories from being version controlled.
File states
gitignore – Ignoring files
 .gitignore file specifies files that Git should ignore
 gitignore – specifies untracked files to ignore
 only untracked files can be ignored
 Files already tracked by Git are not affected
 .gitignore uses globbing patterns to match against file names
 untrack a file example : git rm --cached "New Microsoft Excel Worksheet.xlsx“
 untrack all “dll” files : git rm --cached *.dll
gitignore – Ignoring files (Examples)
Pattern Explanation Example matches
**/logs logs directories anywhere
in the repository.
logs/debug.log
logs/monday/foo.bar
build/logs/debug.log
**/logs/debug.log All debug.log files which
are in logs directory
logs/debug.log
build/logs/debug.log
but not
logs/build/debug.log
*.log
!important.log
debug.log
trace.log
but not
important.log
logs/important.log
All log files but not
the files named
important.log
The staging area
 git add - adds files, folders to the staging area
 Examples : git add <file>, git add <directory>, git add hello.py, git add .
 git commit – commits/saves files only existing in the staging area
 The staging area stores information on what will go into your next commit
Commits
 Every commit has SHA1 hash that uniquely represents a commit
Branching out – Introduction 1
 If you make some changes and commit again, the next commit stores a pointer to the
commit that came immediately before it.
 A branch in Git is simply a lightweight movable pointer to one of these commits.
 The default branch name in Git is master. git init command creates it by default and
most people don’t bother to change it.
Branching out – Introduction 2
 Every time you commit, the current branch (initially master) pointer moves forward
automatically.
Branching out – Creating new branch
 When you create a new branch it creates a new pointer pointing to the latest
commit.
 to create a new branch called testing run this git branch command:
$ git branch testing
 This creates a new pointer to the same commit you’re currently on.
Branching out – HEAD
 How does Git know what branch you’re currently on?
 It keeps a special pointer called HEAD
 this is a pointer to the local branch you’re currently on
Branching out – Switching branches
 To switch to the existing branch testing branch run the following command:
$ git checkout testing
 This moves HEAD to point to the testing branch
Branching out - Advancing
 After checking out testing branch let’s do another commit
 HEAD branch moves forward when a commit is made
 testing branch has moved forward
 master branch still points to the commit it was on when switched branches
Branching out – Switching back
 Let’s switch back to the master branch:
$ git checkout master
 HEAD pointer is moved back to point to the master branch
 the files in your working directory are reverted back to the snapshot that master
points to
Branching out – Diverging
 After checking out master branch let’s do another commit
 HEAD branch moves forward when a commit is made
 master branch has moved forward
Branching out – Some commands
 $ git branch – list branches
 $ git branch develop – create new branch develop
 $ git checkout develop – switch to develop branch
 $ git checkout -b hotfix – create hotfix branch and switch to it
 $ git branch -d issue1 – delete local branch issue1
 $ git branch -m developer develop – rename developer branch into develop
Merging – Initial state
Merging – Fast forwarding
 Merging hotfix into master by running the following commands :
$ git checkout master
$ git merge hotfix
Merging – Delete merged branch
 delete the hotfix branch, we longer need it, the master branch points at the same place
$ git branch -d hotfix
 add new commit C5 in iss53 branch
Merging - Three-way merge
 Merging iss53 into master
$ git checkout master
$ git merge iss53
 Git does a simple three-way by using common ancestor (C2) and two snapshots
(C4 & C5)
Merge Conflicts
 If you changed the same part of the same file differently in the two branches you’re
merging, Git won’t be able to merge them cleanly.
 you’ll get a merge conflict that looks something like
$ git merge iss53
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
Merge Conflicts - Status
 Anything that has merge conflicts and hasn’t been resolved is listed as unmerged.
 If you want to see which files are unmerged at any point after a merge conflict, you can run git status:
$ git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: index.html
no changes added to commit (use "git add" and/or "git commit -a")
Merge Conflicts – Resolution markers
 Git adds standard conflict-resolution markers to the files that have conflicts
 you can open them manually and resolve those conflicts
 your file contains a section that looks something like this:
<<<<<<< HEAD:index.html
<div id="footer">contact : email.support@github.com</div>
=======
<div id="footer">
please contact us at support@github.com
</div>
>>>>>>> iss53:index.html
Merge Conflicts - Finalization
 Remove conflict-resolution markers
 choose one side or the other or merge the contents yourself
 to use a graphical tool to resolve these issues, you can run git mergetool
 run git status again to verify that all conflicts have been resolved
 type git commit to finalize the merge commit
References
 https://www.atlassian.com/git/tutorials/saving-changes
 https://www.atlassian.com/git/tutorials/saving-changes/gitignore
 https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow
 https://www.atlassian.com/git/tutorials/why-git
 https://www.atlassian.com/git/tutorials/what-is-version-control
 https://www.tigraine.at/2016/10/22/git-isnt-magic
 https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
 https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell
 https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

More Related Content

What's hot

Git Tricks
Git TricksGit Tricks
Git Tricks
Ivelina Dimova
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
Yash
 
Git commands
Git commandsGit commands
Git commands
Viyaan Jhiingade
 
Git presentation
Git presentationGit presentation
Git presentation
Sai Kumar Satapathy
 
Common Git Commands
Common Git CommandsCommon Git Commands
Common Git Commands
HTS Hosting
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
Medhat Dawoud
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
Aditya Tiwari
 
Git basic
Git basicGit basic
Git basic
Akbar Uddin
 
SessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystemsSessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystems
Hellen Gakuruh
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginners
bryanbibat
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
Abdul Basit
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
SheilaJimenezMorejon
 
Version Control
Version ControlVersion Control
Version Control
Matt Stoner
 
Git github
Git githubGit github
Git github
Anurag Deb
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-real
Eneldo Serrata
 
Git presentation
Git presentationGit presentation
Git presentation
Vikas Yaligar
 
Git workflows automat-it
Git workflows automat-itGit workflows automat-it
Git workflows automat-it
Automat-IT
 
Atlassian git cheatsheet
Atlassian git cheatsheetAtlassian git cheatsheet
Atlassian git cheatsheet
Abdul Basit
 

What's hot (19)

Git Tricks
Git TricksGit Tricks
Git Tricks
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
Git commands
Git commandsGit commands
Git commands
 
Git presentation
Git presentationGit presentation
Git presentation
 
Common Git Commands
Common Git CommandsCommon Git Commands
Common Git Commands
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Git basic
Git basicGit basic
Git basic
 
SessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystemsSessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystems
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginners
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
 
Version Control
Version ControlVersion Control
Version Control
 
Git github
Git githubGit github
Git github
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-real
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git workflows automat-it
Git workflows automat-itGit workflows automat-it
Git workflows automat-it
 
Atlassian git cheatsheet
Atlassian git cheatsheetAtlassian git cheatsheet
Atlassian git cheatsheet
 

Similar to Git - Version Control System

Git for developers
Git for developersGit for developers
Git for developers
Hacen Dadda
 
Git hub
Git hubGit hub
Git hub
Nitin Goel
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
Mithilesh Singh
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
Yeasin Abedin
 
Git 101
Git 101Git 101
Git 101
jayrparro
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
HuthaifaAlmaqrami1
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
King Hom
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
King Hom
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
King Hom
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat Malladi
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
ssusered2ec2
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GIT
Zeeshan Khan
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
9 series
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
Tahsin Abrar
 
Git workshop
Git workshopGit workshop
Git workshop
Mateusz Galazyn
 
Git_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGit_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_Guidewire
Gandhi Ramu
 
git2.ppt
git2.pptgit2.ppt
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
 

Similar to Git - Version Control System (20)

Git for developers
Git for developersGit for developers
Git for developers
 
Git hub
Git hubGit hub
Git hub
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
Git introduction
Git introductionGit introduction
Git introduction
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
 
Git 101
Git 101Git 101
Git 101
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GIT
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
 
Git workshop
Git workshopGit workshop
Git workshop
 
Git_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGit_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_Guidewire
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 

Recently uploaded

在线办理(UNE毕业证书)新英格兰大学毕业证成绩单一模一样
在线办理(UNE毕业证书)新英格兰大学毕业证成绩单一模一样在线办理(UNE毕业证书)新英格兰大学毕业证成绩单一模一样
在线办理(UNE毕业证书)新英格兰大学毕业证成绩单一模一样
15e6o6u
 
一比一原版朴次茅斯大学毕业证(uop毕业证)如何办理
一比一原版朴次茅斯大学毕业证(uop毕业证)如何办理一比一原版朴次茅斯大学毕业证(uop毕业证)如何办理
一比一原版朴次茅斯大学毕业证(uop毕业证)如何办理
onduyv
 
一比一原版新加坡南洋理工大学毕业证(本硕)ntu学位证书如何办理
一比一原版新加坡南洋理工大学毕业证(本硕)ntu学位证书如何办理一比一原版新加坡南洋理工大学毕业证(本硕)ntu学位证书如何办理
一比一原版新加坡南洋理工大学毕业证(本硕)ntu学位证书如何办理
hedonxu
 
The Future of Criminal Defense Lawyer in India.pdf
The Future of Criminal Defense Lawyer in India.pdfThe Future of Criminal Defense Lawyer in India.pdf
The Future of Criminal Defense Lawyer in India.pdf
veteranlegal
 
原版定做(sheffield学位证书)英国谢菲尔德大学毕业证文凭证书原版一模一样
原版定做(sheffield学位证书)英国谢菲尔德大学毕业证文凭证书原版一模一样原版定做(sheffield学位证书)英国谢菲尔德大学毕业证文凭证书原版一模一样
原版定做(sheffield学位证书)英国谢菲尔德大学毕业证文凭证书原版一模一样
abondo3
 
一比一原版(glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(glasgow毕业证书)格拉斯哥大学毕业证如何办理
ooqzo
 
一比一原版新加坡国立大学毕业证(本硕)nus学位证书如何办理
一比一原版新加坡国立大学毕业证(本硕)nus学位证书如何办理一比一原版新加坡国立大学毕业证(本硕)nus学位证书如何办理
一比一原版新加坡国立大学毕业证(本硕)nus学位证书如何办理
ucoux1
 
PPT-Money Laundering - lecture 5.pptx ll
PPT-Money Laundering - lecture 5.pptx llPPT-Money Laundering - lecture 5.pptx ll
PPT-Money Laundering - lecture 5.pptx ll
MohammadZubair874462
 
THE CONCEPT OF RIGHT TO DEFAULT BAIL.pptx
THE CONCEPT OF RIGHT TO DEFAULT BAIL.pptxTHE CONCEPT OF RIGHT TO DEFAULT BAIL.pptx
THE CONCEPT OF RIGHT TO DEFAULT BAIL.pptx
Namrata Chakraborty
 
Pedal to the Court Understanding Your Rights after a Cycling Collision.pdf
Pedal to the Court Understanding Your Rights after a Cycling Collision.pdfPedal to the Court Understanding Your Rights after a Cycling Collision.pdf
Pedal to the Court Understanding Your Rights after a Cycling Collision.pdf
SunsetWestLegalGroup
 
一比一原版(liverpool毕业证书)利物浦大学毕业证如何办理
一比一原版(liverpool毕业证书)利物浦大学毕业证如何办理一比一原版(liverpool毕业证书)利物浦大学毕业证如何办理
一比一原版(liverpool毕业证书)利物浦大学毕业证如何办理
aypxuyw
 
Safeguarding Against Financial Crime: AML Compliance Regulations Demystified
Safeguarding Against Financial Crime: AML Compliance Regulations DemystifiedSafeguarding Against Financial Crime: AML Compliance Regulations Demystified
Safeguarding Against Financial Crime: AML Compliance Regulations Demystified
PROF. PAUL ALLIEU KAMARA
 
一比一原版(uwlc毕业证书)美国威斯康星大学拉克罗斯分校毕业证如何办理
一比一原版(uwlc毕业证书)美国威斯康星大学拉克罗斯分校毕业证如何办理一比一原版(uwlc毕业证书)美国威斯康星大学拉克罗斯分校毕业证如何办理
一比一原版(uwlc毕业证书)美国威斯康星大学拉克罗斯分校毕业证如何办理
qevye
 
Business Laws Sunita saha
Business Laws Sunita sahaBusiness Laws Sunita saha
Business Laws Sunita saha
sunitasaha5
 
The Work Permit for Self-Employed Persons in Italy
The Work Permit for Self-Employed Persons in ItalyThe Work Permit for Self-Employed Persons in Italy
The Work Permit for Self-Employed Persons in Italy
BridgeWest.eu
 
一比一原版英国伦敦商学院毕业证(lbs毕业证书)如何办理
一比一原版英国伦敦商学院毕业证(lbs毕业证书)如何办理一比一原版英国伦敦商学院毕业证(lbs毕业证书)如何办理
一比一原版英国伦敦商学院毕业证(lbs毕业证书)如何办理
gedsuu
 
一比一原版牛津布鲁克斯大学毕业证(牛布毕业证)如何办理
一比一原版牛津布鲁克斯大学毕业证(牛布毕业证)如何办理一比一原版牛津布鲁克斯大学毕业证(牛布毕业证)如何办理
一比一原版牛津布鲁克斯大学毕业证(牛布毕业证)如何办理
meboh
 
San Remo Manual on International Law Applicable to Armed Conflict at Sea
San Remo Manual on International Law Applicable to Armed Conflict at SeaSan Remo Manual on International Law Applicable to Armed Conflict at Sea
San Remo Manual on International Law Applicable to Armed Conflict at Sea
Justin Ordoyo
 
From Promise to Practice. Implementing AI in Legal Environments
From Promise to Practice. Implementing AI in Legal EnvironmentsFrom Promise to Practice. Implementing AI in Legal Environments
From Promise to Practice. Implementing AI in Legal Environments
ssusera97a2f
 
一比一原版(uwgb毕业证书)美国威斯康星大学绿湾分校毕业证如何办理
一比一原版(uwgb毕业证书)美国威斯康星大学绿湾分校毕业证如何办理一比一原版(uwgb毕业证书)美国威斯康星大学绿湾分校毕业证如何办理
一比一原版(uwgb毕业证书)美国威斯康星大学绿湾分校毕业证如何办理
pdeehy
 

Recently uploaded (20)

在线办理(UNE毕业证书)新英格兰大学毕业证成绩单一模一样
在线办理(UNE毕业证书)新英格兰大学毕业证成绩单一模一样在线办理(UNE毕业证书)新英格兰大学毕业证成绩单一模一样
在线办理(UNE毕业证书)新英格兰大学毕业证成绩单一模一样
 
一比一原版朴次茅斯大学毕业证(uop毕业证)如何办理
一比一原版朴次茅斯大学毕业证(uop毕业证)如何办理一比一原版朴次茅斯大学毕业证(uop毕业证)如何办理
一比一原版朴次茅斯大学毕业证(uop毕业证)如何办理
 
一比一原版新加坡南洋理工大学毕业证(本硕)ntu学位证书如何办理
一比一原版新加坡南洋理工大学毕业证(本硕)ntu学位证书如何办理一比一原版新加坡南洋理工大学毕业证(本硕)ntu学位证书如何办理
一比一原版新加坡南洋理工大学毕业证(本硕)ntu学位证书如何办理
 
The Future of Criminal Defense Lawyer in India.pdf
The Future of Criminal Defense Lawyer in India.pdfThe Future of Criminal Defense Lawyer in India.pdf
The Future of Criminal Defense Lawyer in India.pdf
 
原版定做(sheffield学位证书)英国谢菲尔德大学毕业证文凭证书原版一模一样
原版定做(sheffield学位证书)英国谢菲尔德大学毕业证文凭证书原版一模一样原版定做(sheffield学位证书)英国谢菲尔德大学毕业证文凭证书原版一模一样
原版定做(sheffield学位证书)英国谢菲尔德大学毕业证文凭证书原版一模一样
 
一比一原版(glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
一比一原版新加坡国立大学毕业证(本硕)nus学位证书如何办理
一比一原版新加坡国立大学毕业证(本硕)nus学位证书如何办理一比一原版新加坡国立大学毕业证(本硕)nus学位证书如何办理
一比一原版新加坡国立大学毕业证(本硕)nus学位证书如何办理
 
PPT-Money Laundering - lecture 5.pptx ll
PPT-Money Laundering - lecture 5.pptx llPPT-Money Laundering - lecture 5.pptx ll
PPT-Money Laundering - lecture 5.pptx ll
 
THE CONCEPT OF RIGHT TO DEFAULT BAIL.pptx
THE CONCEPT OF RIGHT TO DEFAULT BAIL.pptxTHE CONCEPT OF RIGHT TO DEFAULT BAIL.pptx
THE CONCEPT OF RIGHT TO DEFAULT BAIL.pptx
 
Pedal to the Court Understanding Your Rights after a Cycling Collision.pdf
Pedal to the Court Understanding Your Rights after a Cycling Collision.pdfPedal to the Court Understanding Your Rights after a Cycling Collision.pdf
Pedal to the Court Understanding Your Rights after a Cycling Collision.pdf
 
一比一原版(liverpool毕业证书)利物浦大学毕业证如何办理
一比一原版(liverpool毕业证书)利物浦大学毕业证如何办理一比一原版(liverpool毕业证书)利物浦大学毕业证如何办理
一比一原版(liverpool毕业证书)利物浦大学毕业证如何办理
 
Safeguarding Against Financial Crime: AML Compliance Regulations Demystified
Safeguarding Against Financial Crime: AML Compliance Regulations DemystifiedSafeguarding Against Financial Crime: AML Compliance Regulations Demystified
Safeguarding Against Financial Crime: AML Compliance Regulations Demystified
 
一比一原版(uwlc毕业证书)美国威斯康星大学拉克罗斯分校毕业证如何办理
一比一原版(uwlc毕业证书)美国威斯康星大学拉克罗斯分校毕业证如何办理一比一原版(uwlc毕业证书)美国威斯康星大学拉克罗斯分校毕业证如何办理
一比一原版(uwlc毕业证书)美国威斯康星大学拉克罗斯分校毕业证如何办理
 
Business Laws Sunita saha
Business Laws Sunita sahaBusiness Laws Sunita saha
Business Laws Sunita saha
 
The Work Permit for Self-Employed Persons in Italy
The Work Permit for Self-Employed Persons in ItalyThe Work Permit for Self-Employed Persons in Italy
The Work Permit for Self-Employed Persons in Italy
 
一比一原版英国伦敦商学院毕业证(lbs毕业证书)如何办理
一比一原版英国伦敦商学院毕业证(lbs毕业证书)如何办理一比一原版英国伦敦商学院毕业证(lbs毕业证书)如何办理
一比一原版英国伦敦商学院毕业证(lbs毕业证书)如何办理
 
一比一原版牛津布鲁克斯大学毕业证(牛布毕业证)如何办理
一比一原版牛津布鲁克斯大学毕业证(牛布毕业证)如何办理一比一原版牛津布鲁克斯大学毕业证(牛布毕业证)如何办理
一比一原版牛津布鲁克斯大学毕业证(牛布毕业证)如何办理
 
San Remo Manual on International Law Applicable to Armed Conflict at Sea
San Remo Manual on International Law Applicable to Armed Conflict at SeaSan Remo Manual on International Law Applicable to Armed Conflict at Sea
San Remo Manual on International Law Applicable to Armed Conflict at Sea
 
From Promise to Practice. Implementing AI in Legal Environments
From Promise to Practice. Implementing AI in Legal EnvironmentsFrom Promise to Practice. Implementing AI in Legal Environments
From Promise to Practice. Implementing AI in Legal Environments
 
一比一原版(uwgb毕业证书)美国威斯康星大学绿湾分校毕业证如何办理
一比一原版(uwgb毕业证书)美国威斯康星大学绿湾分校毕业证如何办理一比一原版(uwgb毕业证书)美国威斯康星大学绿湾分校毕业证如何办理
一比一原版(uwgb毕业证书)美国威斯康星大学绿湾分校毕业证如何办理
 

Git - Version Control System

  • 2. What is a Version Control System (VCS)  a software utility that tracks and manages changes to a file system.  kind of "database". lets you save changes and take a look over time.  tracks the addition, deletion, and modification actions applied to files and directories.  offers collaborative utilities to share and integrate these file system changes to other VCS users.
  • 3. Primary benefits of a VCS  A complete long-term change history of every file.  Branching and merging.  Traceability
  • 4. Most popular version controls systems Source : https://www.openhub.net/ VCS’s in Open Source Projects
  • 6. “Tools” to get started with Git  Git itself. Download from official site https://git-scm.com/downloads  Git Bash. Convenient Command Prompt (Terminal) for Windows to run Git commands and Unix commands such as cat, touch etc.  Git GUI Clients : GitHub Desktop, GitKraken, SmartGit, SourceTree, TortoiseGit.  Even more GUI clients at https://git-scm.com/downloads/guis  IDE integrated Git tools and plugins to work with Git. Most IDE’s have built in tools or plugins to support Git.
  • 7. Git basic commands  git init – initializes current directory as Git repository  git add - adds file(s) to “Staging Area”  git commit – creates new commit/version.  git status – shows the working tree (files & directories) status  git log – list commits  gitignore – prevent files and directories from being version controlled.
  • 9. gitignore – Ignoring files  .gitignore file specifies files that Git should ignore  gitignore – specifies untracked files to ignore  only untracked files can be ignored  Files already tracked by Git are not affected  .gitignore uses globbing patterns to match against file names  untrack a file example : git rm --cached "New Microsoft Excel Worksheet.xlsx“  untrack all “dll” files : git rm --cached *.dll
  • 10. gitignore – Ignoring files (Examples) Pattern Explanation Example matches **/logs logs directories anywhere in the repository. logs/debug.log logs/monday/foo.bar build/logs/debug.log **/logs/debug.log All debug.log files which are in logs directory logs/debug.log build/logs/debug.log but not logs/build/debug.log *.log !important.log debug.log trace.log but not important.log logs/important.log All log files but not the files named important.log
  • 11. The staging area  git add - adds files, folders to the staging area  Examples : git add <file>, git add <directory>, git add hello.py, git add .  git commit – commits/saves files only existing in the staging area  The staging area stores information on what will go into your next commit
  • 12. Commits  Every commit has SHA1 hash that uniquely represents a commit
  • 13. Branching out – Introduction 1  If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it.  A branch in Git is simply a lightweight movable pointer to one of these commits.  The default branch name in Git is master. git init command creates it by default and most people don’t bother to change it.
  • 14. Branching out – Introduction 2  Every time you commit, the current branch (initially master) pointer moves forward automatically.
  • 15. Branching out – Creating new branch  When you create a new branch it creates a new pointer pointing to the latest commit.  to create a new branch called testing run this git branch command: $ git branch testing  This creates a new pointer to the same commit you’re currently on.
  • 16. Branching out – HEAD  How does Git know what branch you’re currently on?  It keeps a special pointer called HEAD  this is a pointer to the local branch you’re currently on
  • 17. Branching out – Switching branches  To switch to the existing branch testing branch run the following command: $ git checkout testing  This moves HEAD to point to the testing branch
  • 18. Branching out - Advancing  After checking out testing branch let’s do another commit  HEAD branch moves forward when a commit is made  testing branch has moved forward  master branch still points to the commit it was on when switched branches
  • 19. Branching out – Switching back  Let’s switch back to the master branch: $ git checkout master  HEAD pointer is moved back to point to the master branch  the files in your working directory are reverted back to the snapshot that master points to
  • 20. Branching out – Diverging  After checking out master branch let’s do another commit  HEAD branch moves forward when a commit is made  master branch has moved forward
  • 21. Branching out – Some commands  $ git branch – list branches  $ git branch develop – create new branch develop  $ git checkout develop – switch to develop branch  $ git checkout -b hotfix – create hotfix branch and switch to it  $ git branch -d issue1 – delete local branch issue1  $ git branch -m developer develop – rename developer branch into develop
  • 23. Merging – Fast forwarding  Merging hotfix into master by running the following commands : $ git checkout master $ git merge hotfix
  • 24. Merging – Delete merged branch  delete the hotfix branch, we longer need it, the master branch points at the same place $ git branch -d hotfix  add new commit C5 in iss53 branch
  • 25. Merging - Three-way merge  Merging iss53 into master $ git checkout master $ git merge iss53  Git does a simple three-way by using common ancestor (C2) and two snapshots (C4 & C5)
  • 26. Merge Conflicts  If you changed the same part of the same file differently in the two branches you’re merging, Git won’t be able to merge them cleanly.  you’ll get a merge conflict that looks something like $ git merge iss53 Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result.
  • 27. Merge Conflicts - Status  Anything that has merge conflicts and hasn’t been resolved is listed as unmerged.  If you want to see which files are unmerged at any point after a merge conflict, you can run git status: $ git status On branch master You have unmerged paths. (fix conflicts and run "git commit") Unmerged paths: (use "git add <file>..." to mark resolution) both modified: index.html no changes added to commit (use "git add" and/or "git commit -a")
  • 28. Merge Conflicts – Resolution markers  Git adds standard conflict-resolution markers to the files that have conflicts  you can open them manually and resolve those conflicts  your file contains a section that looks something like this: <<<<<<< HEAD:index.html <div id="footer">contact : email.support@github.com</div> ======= <div id="footer"> please contact us at support@github.com </div> >>>>>>> iss53:index.html
  • 29. Merge Conflicts - Finalization  Remove conflict-resolution markers  choose one side or the other or merge the contents yourself  to use a graphical tool to resolve these issues, you can run git mergetool  run git status again to verify that all conflicts have been resolved  type git commit to finalize the merge commit
  • 30. References  https://www.atlassian.com/git/tutorials/saving-changes  https://www.atlassian.com/git/tutorials/saving-changes/gitignore  https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow  https://www.atlassian.com/git/tutorials/why-git  https://www.atlassian.com/git/tutorials/what-is-version-control  https://www.tigraine.at/2016/10/22/git-isnt-magic  https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository  https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell  https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

Editor's Notes

  1. 871945c862ba88467c8e698e7949fa1528a5b83c