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

Weitere ähnliche Inhalte

Was ist angesagt?

Git Terminologies
Git TerminologiesGit Terminologies
Git TerminologiesYash
 
Common Git Commands
Common Git CommandsCommon Git Commands
Common Git CommandsHTS Hosting
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucketMedhat Dawoud
 
SessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystemsSessionThree_IntroductionToVersionControlSystems
SessionThree_IntroductionToVersionControlSystemsHellen Gakuruh
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginnersbryanbibat
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshellalignan
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheetAbdul Basit
 
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-realEneldo Serrata
 
Git workflows automat-it
Git workflows automat-itGit workflows automat-it
Git workflows automat-itAutomat-IT
 
Atlassian git cheatsheet
Atlassian git cheatsheetAtlassian git cheatsheet
Atlassian git cheatsheetAbdul Basit
 

Was ist angesagt? (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
 

Ähnlich wie Git - Version Control System

Git for developers
Git for developersGit for developers
Git for developersHacen Dadda
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)Yeasin Abedin
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__greyKing Hom
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__whiteKing Hom
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_darkKing 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 hubVenkat Malladi
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GITZeeshan 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 - WorkflowTahsin Abrar
 
Git_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGit_and_GitHub Integration_with_Guidewire
Git_and_GitHub Integration_with_GuidewireGandhi Ramu
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 

Ähnlich wie 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__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
 
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
 

Kürzlich hochgeladen

Navigating the Legal and Ethical Landscape of Blockchain Investigation.pdf
Navigating the Legal and Ethical Landscape of Blockchain Investigation.pdfNavigating the Legal and Ethical Landscape of Blockchain Investigation.pdf
Navigating the Legal and Ethical Landscape of Blockchain Investigation.pdfMilind Agarwal
 
CAFC Chronicles: Costly Tales of Claim Construction Fails
CAFC Chronicles: Costly Tales of Claim Construction FailsCAFC Chronicles: Costly Tales of Claim Construction Fails
CAFC Chronicles: Costly Tales of Claim Construction FailsAurora Consulting
 
3 Formation of Company.www.seribangash.com.ppt
3 Formation of Company.www.seribangash.com.ppt3 Formation of Company.www.seribangash.com.ppt
3 Formation of Company.www.seribangash.com.pptseri bangash
 
589308994-interpretation-of-statutes-notes-law-college.pdf
589308994-interpretation-of-statutes-notes-law-college.pdf589308994-interpretation-of-statutes-notes-law-college.pdf
589308994-interpretation-of-statutes-notes-law-college.pdfSUSHMITAPOTHAL
 
Relationship Between International Law and Municipal Law MIR.pdf
Relationship Between International Law and Municipal Law MIR.pdfRelationship Between International Law and Municipal Law MIR.pdf
Relationship Between International Law and Municipal Law MIR.pdfKelechi48
 
Clarifying Land Donation Issues Memo for
Clarifying Land Donation Issues Memo forClarifying Land Donation Issues Memo for
Clarifying Land Donation Issues Memo forRoger Valdez
 
8. SECURITY GUARD CREED, CODE OF CONDUCT, COPE.pptx
8. SECURITY GUARD CREED, CODE OF CONDUCT, COPE.pptx8. SECURITY GUARD CREED, CODE OF CONDUCT, COPE.pptx
8. SECURITY GUARD CREED, CODE OF CONDUCT, COPE.pptxPamelaAbegailMonsant2
 
Navigating Employment Law - Term Project.pptx
Navigating Employment Law - Term Project.pptxNavigating Employment Law - Term Project.pptx
Navigating Employment Law - Term Project.pptxelysemiller87
 
Contract law. Indemnity
Contract law.                     IndemnityContract law.                     Indemnity
Contract law. Indemnitymahikaanand16
 
一比一原版(ECU毕业证书)埃迪斯科文大学毕业证如何办理
一比一原版(ECU毕业证书)埃迪斯科文大学毕业证如何办理一比一原版(ECU毕业证书)埃迪斯科文大学毕业证如何办理
一比一原版(ECU毕业证书)埃迪斯科文大学毕业证如何办理Airst S
 
How do cyber crime lawyers in Mumbai collaborate with law enforcement agencie...
How do cyber crime lawyers in Mumbai collaborate with law enforcement agencie...How do cyber crime lawyers in Mumbai collaborate with law enforcement agencie...
How do cyber crime lawyers in Mumbai collaborate with law enforcement agencie...Finlaw Associates
 
一比一原版曼彻斯特城市大学毕业证如何办理
一比一原版曼彻斯特城市大学毕业证如何办理一比一原版曼彻斯特城市大学毕业证如何办理
一比一原版曼彻斯特城市大学毕业证如何办理Airst S
 
MOCK GENERAL MEETINGS (SS-2)- PPT- Part 2.pptx
MOCK GENERAL MEETINGS (SS-2)- PPT- Part 2.pptxMOCK GENERAL MEETINGS (SS-2)- PPT- Part 2.pptx
MOCK GENERAL MEETINGS (SS-2)- PPT- Part 2.pptxRRR Chambers
 
Police Misconduct Lawyers - Law Office of Jerry L. Steering
Police Misconduct Lawyers - Law Office of Jerry L. SteeringPolice Misconduct Lawyers - Law Office of Jerry L. Steering
Police Misconduct Lawyers - Law Office of Jerry L. SteeringSteering Law
 
Human Rights_FilippoLuciani diritti umani.pptx
Human Rights_FilippoLuciani diritti umani.pptxHuman Rights_FilippoLuciani diritti umani.pptx
Human Rights_FilippoLuciani diritti umani.pptxfilippoluciani9
 
A SHORT HISTORY OF LIBERTY'S PROGREE THROUGH HE EIGHTEENTH CENTURY
A SHORT HISTORY OF LIBERTY'S PROGREE THROUGH HE EIGHTEENTH CENTURYA SHORT HISTORY OF LIBERTY'S PROGREE THROUGH HE EIGHTEENTH CENTURY
A SHORT HISTORY OF LIBERTY'S PROGREE THROUGH HE EIGHTEENTH CENTURYJulian Scutts
 
Cyber Laws : National and International Perspective.
Cyber Laws : National and International Perspective.Cyber Laws : National and International Perspective.
Cyber Laws : National and International Perspective.Nilendra Kumar
 
一比一原版(UC毕业证书)堪培拉大学毕业证如何办理
一比一原版(UC毕业证书)堪培拉大学毕业证如何办理一比一原版(UC毕业证书)堪培拉大学毕业证如何办理
一比一原版(UC毕业证书)堪培拉大学毕业证如何办理bd2c5966a56d
 
Hely-Hutchinson v. Brayhead Ltd .pdf
Hely-Hutchinson v. Brayhead Ltd         .pdfHely-Hutchinson v. Brayhead Ltd         .pdf
Hely-Hutchinson v. Brayhead Ltd .pdfBritto Valan
 
WhatsApp 📞 8448380779 ✅Call Girls In Nangli Wazidpur Sector 135 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Nangli Wazidpur Sector 135 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Nangli Wazidpur Sector 135 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Nangli Wazidpur Sector 135 ( Noida)Delhi Call girls
 

Kürzlich hochgeladen (20)

Navigating the Legal and Ethical Landscape of Blockchain Investigation.pdf
Navigating the Legal and Ethical Landscape of Blockchain Investigation.pdfNavigating the Legal and Ethical Landscape of Blockchain Investigation.pdf
Navigating the Legal and Ethical Landscape of Blockchain Investigation.pdf
 
CAFC Chronicles: Costly Tales of Claim Construction Fails
CAFC Chronicles: Costly Tales of Claim Construction FailsCAFC Chronicles: Costly Tales of Claim Construction Fails
CAFC Chronicles: Costly Tales of Claim Construction Fails
 
3 Formation of Company.www.seribangash.com.ppt
3 Formation of Company.www.seribangash.com.ppt3 Formation of Company.www.seribangash.com.ppt
3 Formation of Company.www.seribangash.com.ppt
 
589308994-interpretation-of-statutes-notes-law-college.pdf
589308994-interpretation-of-statutes-notes-law-college.pdf589308994-interpretation-of-statutes-notes-law-college.pdf
589308994-interpretation-of-statutes-notes-law-college.pdf
 
Relationship Between International Law and Municipal Law MIR.pdf
Relationship Between International Law and Municipal Law MIR.pdfRelationship Between International Law and Municipal Law MIR.pdf
Relationship Between International Law and Municipal Law MIR.pdf
 
Clarifying Land Donation Issues Memo for
Clarifying Land Donation Issues Memo forClarifying Land Donation Issues Memo for
Clarifying Land Donation Issues Memo for
 
8. SECURITY GUARD CREED, CODE OF CONDUCT, COPE.pptx
8. SECURITY GUARD CREED, CODE OF CONDUCT, COPE.pptx8. SECURITY GUARD CREED, CODE OF CONDUCT, COPE.pptx
8. SECURITY GUARD CREED, CODE OF CONDUCT, COPE.pptx
 
Navigating Employment Law - Term Project.pptx
Navigating Employment Law - Term Project.pptxNavigating Employment Law - Term Project.pptx
Navigating Employment Law - Term Project.pptx
 
Contract law. Indemnity
Contract law.                     IndemnityContract law.                     Indemnity
Contract law. Indemnity
 
一比一原版(ECU毕业证书)埃迪斯科文大学毕业证如何办理
一比一原版(ECU毕业证书)埃迪斯科文大学毕业证如何办理一比一原版(ECU毕业证书)埃迪斯科文大学毕业证如何办理
一比一原版(ECU毕业证书)埃迪斯科文大学毕业证如何办理
 
How do cyber crime lawyers in Mumbai collaborate with law enforcement agencie...
How do cyber crime lawyers in Mumbai collaborate with law enforcement agencie...How do cyber crime lawyers in Mumbai collaborate with law enforcement agencie...
How do cyber crime lawyers in Mumbai collaborate with law enforcement agencie...
 
一比一原版曼彻斯特城市大学毕业证如何办理
一比一原版曼彻斯特城市大学毕业证如何办理一比一原版曼彻斯特城市大学毕业证如何办理
一比一原版曼彻斯特城市大学毕业证如何办理
 
MOCK GENERAL MEETINGS (SS-2)- PPT- Part 2.pptx
MOCK GENERAL MEETINGS (SS-2)- PPT- Part 2.pptxMOCK GENERAL MEETINGS (SS-2)- PPT- Part 2.pptx
MOCK GENERAL MEETINGS (SS-2)- PPT- Part 2.pptx
 
Police Misconduct Lawyers - Law Office of Jerry L. Steering
Police Misconduct Lawyers - Law Office of Jerry L. SteeringPolice Misconduct Lawyers - Law Office of Jerry L. Steering
Police Misconduct Lawyers - Law Office of Jerry L. Steering
 
Human Rights_FilippoLuciani diritti umani.pptx
Human Rights_FilippoLuciani diritti umani.pptxHuman Rights_FilippoLuciani diritti umani.pptx
Human Rights_FilippoLuciani diritti umani.pptx
 
A SHORT HISTORY OF LIBERTY'S PROGREE THROUGH HE EIGHTEENTH CENTURY
A SHORT HISTORY OF LIBERTY'S PROGREE THROUGH HE EIGHTEENTH CENTURYA SHORT HISTORY OF LIBERTY'S PROGREE THROUGH HE EIGHTEENTH CENTURY
A SHORT HISTORY OF LIBERTY'S PROGREE THROUGH HE EIGHTEENTH CENTURY
 
Cyber Laws : National and International Perspective.
Cyber Laws : National and International Perspective.Cyber Laws : National and International Perspective.
Cyber Laws : National and International Perspective.
 
一比一原版(UC毕业证书)堪培拉大学毕业证如何办理
一比一原版(UC毕业证书)堪培拉大学毕业证如何办理一比一原版(UC毕业证书)堪培拉大学毕业证如何办理
一比一原版(UC毕业证书)堪培拉大学毕业证如何办理
 
Hely-Hutchinson v. Brayhead Ltd .pdf
Hely-Hutchinson v. Brayhead Ltd         .pdfHely-Hutchinson v. Brayhead Ltd         .pdf
Hely-Hutchinson v. Brayhead Ltd .pdf
 
WhatsApp 📞 8448380779 ✅Call Girls In Nangli Wazidpur Sector 135 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Nangli Wazidpur Sector 135 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Nangli Wazidpur Sector 135 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Nangli Wazidpur Sector 135 ( Noida)
 

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

Hinweis der Redaktion

  1. 871945c862ba88467c8e698e7949fa1528a5b83c