SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHubVikram SV
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Introduction to git flow
Introduction to git flowIntroduction to git flow
Introduction to git flowKnoldus Inc.
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeMd Swawibe Ul Alam
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Noa Harel
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdfTilton2
 
What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020Noa Harel
 

Tendances (20)

Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
Git training v10
Git training v10Git training v10
Git training v10
 
Git
GitGit
Git
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Introduction to git flow
Introduction to git flowIntroduction to git flow
Introduction to git flow
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
GitLab.pptx
GitLab.pptxGitLab.pptx
GitLab.pptx
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Advanced Git Presentation By Swawibe
Advanced Git Presentation By SwawibeAdvanced Git Presentation By Swawibe
Advanced Git Presentation By Swawibe
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
 
Git and Github slides.pdf
Git and Github slides.pdfGit and Github slides.pdf
Git and Github slides.pdf
 
What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020
 

Similaire à Version Control System - Git

Similaire à 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
 

Dernier

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 

Dernier (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 

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