SlideShare una empresa de Scribd logo
1 de 28
Descargar para leer sin conexión
MILANO 1863
POLITECNICO
Version Control System
REASONS AND GIT
Carlo Bernaschina – carlo.bernaschina@polimi.it
Our day to day work can be described as follow:
• Create
• Save
• Edit
• Save again
• …
Background
DEVELOPMENT CYCLE
Generally we do not work alone.
This process is shared between peoples (developers).
Background
COLLABORATION
Donald:
• Create
• Save
• Edit
• Save again
• …
Emily:
• Create
• Save
• Edit
• Save again
• …
Collisions
We both changed the same file, which one should we
use?
Journaling
Who changed What? When? Why?
The Problem
COLLISIONS & JOURNALING
A Version Control System is not “just” a backup.
It is a tool that enables:
• Parallel Development
• Journaling
• Collaboration
The Solution
VERSION CONTROL SYSTEM
• CVS
• Centralized (Client/Server)
• Subversion “CVS Made Right”
• Atomic operations
• Git
• Decentralized
• Mercurial
• Linear History
Alternatives
FREE VERSION CONTROL SYSTEMS
Git is a Version Control System.
It was developed by Linus Torvalds in 2005 for the
development of the Linux Kernel.
It was originally meant to replace BitKeeper.
Git
A FREE AND OPEN SOURCE ALTERNATIVE
not actually directed to BitKeeper
• Take Concurrent Versions System (CVS) as an
example of what not to do; if in doubt, make the
exact opposite decision
• Support a distributed, BitKeeper-like workflow
• Include very strong safeguards against corruption,
either accidental or malicious
Linus Torvalds
The Original Idea
SOME GUIDING RULES
To create a repository you just need to type:
git init
it creates a repository inside the current folder.
Or:
git init <directory>
it creates a repository inside a specific directory.
git init
HOW DO I CREATE A REPOSITORY?
Let’s Git know who we are. Using:
git config user.name “<your name>"
git config user.email “<your email>"
These information will be attached to each commit
that we are going to do (journaling).
git config
WHO AM I?
Once we have produced some content let’s Git know
what do we want to save (stage for commit).
git add <file>
will stage the specified file for commit.
git add -A
will stage All the files for commit.
git add
WHAT AM I SAVING?
If you want to have a list of the currently
changed/staged files you can list them.
git status
Files can be in different states:
• at revision (no change since last commit)
• changed (added, edited or deleted)
• staged (changed and listed for commit)
git status
WHAT DID I DO?
Once we have staged all the files it is time so actually
commit the changes.
git commit
will open a command line editor and let you specify a
commit message.
git commit -m "<a meaningful commit message>"
the same but easier.
git commit
WHY DID I DO THAT?
Git stores your history of commits.
You move inside the history and start new parallel
development flows called branches.
History
WHAT HAPPENED?
You can always restore the last stored version of a file.
git checkout <file name>
All the local edits will be overwritten.
git checkout
HOW DO I COME BACK?
If you want to preserve the current status of the
repository you can create a new branch (a separate
development flow).
git checkout -b <new branch name>
It will clone the current status of the repository in a new
branch.
git checkout
HOW DO I START DEVELOPING A NEW FEATURE?
If you want to move between the available branches
you can checkout the one you want to work on.
git checkout <branch name>
It will set the selected branch as active.
git checkout
HOW DO I MOVE BETWEEN BRANCHES?
If you want to list all the available branches.
git branch
git branch
HOW DO I LIST MY BRANCHES?
If you want to integrate the changes done in a branch
into another.
Move to the branch you want to merge to and merge
them.
git checkout <target branch>
git merge <source branch>
git merge
HOW DO I INTEGRATE TWO BRANCHES?
If both the branches have a commit that changes the same
content it will generate a conflict.
the number of planets are
<<<<<<< HEAD
nine
=======
Eight
>>>>>>> branch-a
Manually fix them and then commit.
Conflicts
HOW DOES IT MERGE CONFLICTING CONTENT?
If you want to remove branches, just delete them.
git branch -d <branch name>
git branch -d
HOW DO I CLEAN UP?
We just worked with local repositories right now.
How can we collaborate.
Git is decentralized, the copies of the repositories on different
machines describe a graph.
A way to have a “central” copy of the repository that is
accessible to everyone without the need of particular setups is
using sites like:
• github.com
• gitlab.com
Distributed
HOW DO WE COLLABORATE?
If you want to copy a remote repository just clone it.
git clone <address of the repository>
It will copy the remote repository on the local machine.
git clone
HOW DO I COPY A REMOTE REPOSITORY?
If you want keep your clone updated you can pull the
changes from the remote one.
git pull
It will merge the remote changes inside the local
repository.
git pull <remote> <branch>
git pull
HOW DO I UPDATE MY COPY?
If you need/want to maintain sequentiality in the
commits adding your local changes after the others
you can ask the merge utility to apply them after the
others.
git pull --rebase
You will be asked to confirm some of your commits.
git pull --rebase <remote> <branch>
git pull --rebase
HOW DO I KEEP JOURNALING SEQUENTIAL?
If you want to send your local commits to a remote
repository you can push them.
git push
It will copy the local changes on the remote repository.
It requires the last commit in the remote repository to
be known in the local one.
git push <remote> <branch>
git push
HOW DO I UPLOAD MY CHANGES?
Do you want to learn more?
https://try.github.io
Let’s learn
ONLINE LEARNING TOOLS
• https://git-scm.com
• http://www.catb.org/esr/writings/version-
control/version-control.html
• https://www.youtube.com/watch?v=4XpnKHJAok8
• http://marc.info/?l=git&m=118143549107708
Reference

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git basic
Git basicGit basic
Git basic
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git
GitGit
Git
 
Source control
Source controlSource control
Source control
 
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
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Git training v10
Git training v10Git training v10
Git training v10
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git basics
Git basicsGit basics
Git basics
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 

Similar a Version Control System - Git

BSADD-Git-TRAINING
BSADD-Git-TRAININGBSADD-Git-TRAINING
BSADD-Git-TRAINING
bsadd
 

Similar a Version Control System - Git (20)

Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
 
Git github
Git githubGit github
Git github
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
Version controll.pptx
Version controll.pptxVersion controll.pptx
Version controll.pptx
 
Git 101
Git 101Git 101
Git 101
 
BSADD-Git-TRAINING
BSADD-Git-TRAININGBSADD-Git-TRAINING
BSADD-Git-TRAINING
 
Bsadd training-git
Bsadd training-gitBsadd training-git
Bsadd training-git
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Git for developers
Git for developersGit for developers
Git for developers
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptx
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git learning
Git learningGit learning
Git learning
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
01 git interview questions &amp; answers
01   git interview questions &amp; answers01   git interview questions &amp; answers
01 git interview questions &amp; answers
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 

Último

Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Version Control System - Git

  • 1. MILANO 1863 POLITECNICO Version Control System REASONS AND GIT Carlo Bernaschina – carlo.bernaschina@polimi.it
  • 2. Our day to day work can be described as follow: • Create • Save • Edit • Save again • … Background DEVELOPMENT CYCLE
  • 3. Generally we do not work alone. This process is shared between peoples (developers). Background COLLABORATION Donald: • Create • Save • Edit • Save again • … Emily: • Create • Save • Edit • Save again • …
  • 4. Collisions We both changed the same file, which one should we use? Journaling Who changed What? When? Why? The Problem COLLISIONS & JOURNALING
  • 5. A Version Control System is not “just” a backup. It is a tool that enables: • Parallel Development • Journaling • Collaboration The Solution VERSION CONTROL SYSTEM
  • 6. • CVS • Centralized (Client/Server) • Subversion “CVS Made Right” • Atomic operations • Git • Decentralized • Mercurial • Linear History Alternatives FREE VERSION CONTROL SYSTEMS
  • 7. Git is a Version Control System. It was developed by Linus Torvalds in 2005 for the development of the Linux Kernel. It was originally meant to replace BitKeeper. Git A FREE AND OPEN SOURCE ALTERNATIVE not actually directed to BitKeeper
  • 8. • Take Concurrent Versions System (CVS) as an example of what not to do; if in doubt, make the exact opposite decision • Support a distributed, BitKeeper-like workflow • Include very strong safeguards against corruption, either accidental or malicious Linus Torvalds The Original Idea SOME GUIDING RULES
  • 9. To create a repository you just need to type: git init it creates a repository inside the current folder. Or: git init <directory> it creates a repository inside a specific directory. git init HOW DO I CREATE A REPOSITORY?
  • 10. Let’s Git know who we are. Using: git config user.name “<your name>" git config user.email “<your email>" These information will be attached to each commit that we are going to do (journaling). git config WHO AM I?
  • 11. Once we have produced some content let’s Git know what do we want to save (stage for commit). git add <file> will stage the specified file for commit. git add -A will stage All the files for commit. git add WHAT AM I SAVING?
  • 12. If you want to have a list of the currently changed/staged files you can list them. git status Files can be in different states: • at revision (no change since last commit) • changed (added, edited or deleted) • staged (changed and listed for commit) git status WHAT DID I DO?
  • 13. Once we have staged all the files it is time so actually commit the changes. git commit will open a command line editor and let you specify a commit message. git commit -m "<a meaningful commit message>" the same but easier. git commit WHY DID I DO THAT?
  • 14. Git stores your history of commits. You move inside the history and start new parallel development flows called branches. History WHAT HAPPENED?
  • 15. You can always restore the last stored version of a file. git checkout <file name> All the local edits will be overwritten. git checkout HOW DO I COME BACK?
  • 16. If you want to preserve the current status of the repository you can create a new branch (a separate development flow). git checkout -b <new branch name> It will clone the current status of the repository in a new branch. git checkout HOW DO I START DEVELOPING A NEW FEATURE?
  • 17. If you want to move between the available branches you can checkout the one you want to work on. git checkout <branch name> It will set the selected branch as active. git checkout HOW DO I MOVE BETWEEN BRANCHES?
  • 18. If you want to list all the available branches. git branch git branch HOW DO I LIST MY BRANCHES?
  • 19. If you want to integrate the changes done in a branch into another. Move to the branch you want to merge to and merge them. git checkout <target branch> git merge <source branch> git merge HOW DO I INTEGRATE TWO BRANCHES?
  • 20. If both the branches have a commit that changes the same content it will generate a conflict. the number of planets are <<<<<<< HEAD nine ======= Eight >>>>>>> branch-a Manually fix them and then commit. Conflicts HOW DOES IT MERGE CONFLICTING CONTENT?
  • 21. If you want to remove branches, just delete them. git branch -d <branch name> git branch -d HOW DO I CLEAN UP?
  • 22. We just worked with local repositories right now. How can we collaborate. Git is decentralized, the copies of the repositories on different machines describe a graph. A way to have a “central” copy of the repository that is accessible to everyone without the need of particular setups is using sites like: • github.com • gitlab.com Distributed HOW DO WE COLLABORATE?
  • 23. If you want to copy a remote repository just clone it. git clone <address of the repository> It will copy the remote repository on the local machine. git clone HOW DO I COPY A REMOTE REPOSITORY?
  • 24. If you want keep your clone updated you can pull the changes from the remote one. git pull It will merge the remote changes inside the local repository. git pull <remote> <branch> git pull HOW DO I UPDATE MY COPY?
  • 25. If you need/want to maintain sequentiality in the commits adding your local changes after the others you can ask the merge utility to apply them after the others. git pull --rebase You will be asked to confirm some of your commits. git pull --rebase <remote> <branch> git pull --rebase HOW DO I KEEP JOURNALING SEQUENTIAL?
  • 26. If you want to send your local commits to a remote repository you can push them. git push It will copy the local changes on the remote repository. It requires the last commit in the remote repository to be known in the local one. git push <remote> <branch> git push HOW DO I UPLOAD MY CHANGES?
  • 27. Do you want to learn more? https://try.github.io Let’s learn ONLINE LEARNING TOOLS
  • 28. • https://git-scm.com • http://www.catb.org/esr/writings/version- control/version-control.html • https://www.youtube.com/watch?v=4XpnKHJAok8 • http://marc.info/?l=git&m=118143549107708 Reference