SlideShare a Scribd company logo
1 of 21
Download to read offline
Francesco Pira | fpira.com
First steps with Git
Francesco Pira
fpira.com
@pirafrank
me@fpira.com
Linux Day 2016 - Enna (Sicily)
Francesco Pira | fpira.com
Who am I?
• Web developer
• btw currently sys admin
• I like Python
• I’ve founded a startup (no much fuss...)
• I write a blog in my spare time
• ...and some code (github.com/pirafrank)
• I like business
• ...but code is better!
Francesco Pira | fpira.com
What is a VCS?
• VCS stands for Version Control System
• A software to handle different versions of a pool of files
• Great to manage source code
• Something you need to get a job
• Something you need to share your weekend project
• Something you need to deploy and maintain your blog
• See Github Pages, GitLab Pages and Jekyll
Francesco Pira | fpira.com
Why VCS?
• A repository as a unique codebase
• Reliability
• History and changes + easy to roll back at any point
• Blaming (who changed what?)
• Side projects (aka forking a repo)
• Parallel development on the same repo (aka team working)
• Code deployment!
Francesco Pira | fpira.com
Popular VCS software
● Git
● Team Foundation Server (MS)
● Apache Subversion (SVN)
● Mercurial (BitBucket)
● Bazaar (Canonical)
* In order of popularity
Francesco Pira | fpira.com
• repository = a directory with files (usually code!)
• working tree = index of files part of the repo
• ignoring = no to keep track of changes
• staging = virtual area with changes ready to commit
• commit = snapshot of a repository, changes saved in history
• head = pointer to the latest commit of the current branch
• branch = a copy of files to track different changes
• merging = merging the history of a branch with his parent one
• conflict = 2 or more people making changes to same file
• tag = named pointer to a particular snapshot (e.g. v1.1.0)
• remote = server (it can be another PC for distributed VCS)
VCS concepts
Francesco Pira | fpira.com
Who’s Git?
• Created by Linus Torvalds (mid 2005)
• to manage the shared development of Linux kernel
• Today is the most common VCS
• It works using snapshots, pointers and compressed deltas
• All changes and history are in ./.git
• Works best with small files (see git lfs)
• Distribute (remote) architecture
• Used by GitHub: the biggest and de facto standard platform
for sharing open-source code
Francesco Pira | fpira.com
Setup the environment
● Download and install git
○ bit.ly/linux-day-git-install
● Set it up
○ git config --global user.name "My Name"
○ git config --global user.email "my@email.com"
● Remotes require your to have an RSA key: set it up!
○ ssh-keygen -t rsa -b 4096 -C "my@email.com"
○ eval "$(ssh-agent -s)"
○ ssh-add ~/.ssh/id_rsa
Pro tip: Use different RSA keys (personal, work, etc.)
Francesco Pira | fpira.com
Your first commit, yay!
Locally on your computer
• git init
• git add .
• git remote add origin ...
• git commit -m “Hey! This is my first commit”
• git push origin master
Your teammate
• git clone ...
Francesco Pira | fpira.com
Some notes
master is the main and first branch
origin is the primary remote. You push your code to it
Tip: Use --global to make a setting work for all repo of current
local user
Interesting: Git global configuration usually lives here
~/.gitconfig or here ~/.config/git/config
Francesco Pira | fpira.com
Live demo
Francesco Pira | fpira.com
• init = initialise the repository (make ./.git subdir)
• clone = make a local copy of the repo from a remote one
• diff = show current changes (before staging them)
• add = stage one of more file / folders
• commit = make a ‘snapshot’ / save a state
• branch = create a branch off the current one
• merge = merge a branch into his parent
• fetch = download (new) changes from remote
• pull = fetch from remote branch + merge to local one
• checkout = switch branch / restore file in working tree
• reset = undo / remove from staging area
• log = explore changes history
• … tons of commands, each one has tons of parameters: RTFM!
Main Git commands
Francesco Pira | fpira.com
Lazy as a pig? Aliases!
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st 'status -s'
git config --global alias.unstage 'reset HEAD --'
...Make yours!
Francesco Pira | fpira.com
Best practices
• Don’t zip repositories! Use remotes!
• master as the main branch
• devel as the main development branch
• all features start off devel
• all features ends
• usually you don’t push features
• all releases must be tagged (in master)
• use semantic versioning for tags
• hotfix start off master, merged to master and devel
Francesco Pira | fpira.com
Credits to Vincent Driessen
Francesco Pira | fpira.com
Live demo
Francesco Pira | fpira.com
UI clients
● Windows and macOS
○ Sourcetree
● Linux
○ SmartGit
Francesco Pira | fpira.com
Best platforms
● GitHub
○ Free only for open-source public projects
● BitBucket
○ Free for unlimited private or public repos (any license)
○ Paid for 5+ collaborators
● GitLab
○ Paid enterprise version (with support)
○ Free Community Edition (self-hosted)
○ Free gitlab.com: unlimited repos, unlimited collaborators
Francesco Pira | fpira.com
Your turn!
• Wow! git log --graph --oneline --decorate --all
• Discover git stash and git pop
• Deploy best practices
• Use git-flow
• Deploy a web application using git
• Try git-lfs
• ...Have fun!
Francesco Pira | fpira.com
Sources and extras
• https://git-scm.com/book/en/v2/Getting-Started-Git-Basics
• https://help.github.com/articles/generating-a-new-ssh-key-and-addi
ng-it-to-the-ssh-agent/
• https://www.atlassian.com/git/tutorials
• http://nvie.com/posts/a-successful-git-branching-model/
• http://semver.org (semantic versioning)
Francesco Pira | fpira.com
Thank you!
Keep in touch
fpira.com
@pirafrank
me@fpira.com
github.com/ pirafrank

More Related Content

Recently uploaded

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 

Recently uploaded (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 

Featured

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

First steps with Git - Linux Day 2016 - Enna

  • 1. Francesco Pira | fpira.com First steps with Git Francesco Pira fpira.com @pirafrank me@fpira.com Linux Day 2016 - Enna (Sicily)
  • 2. Francesco Pira | fpira.com Who am I? • Web developer • btw currently sys admin • I like Python • I’ve founded a startup (no much fuss...) • I write a blog in my spare time • ...and some code (github.com/pirafrank) • I like business • ...but code is better!
  • 3. Francesco Pira | fpira.com What is a VCS? • VCS stands for Version Control System • A software to handle different versions of a pool of files • Great to manage source code • Something you need to get a job • Something you need to share your weekend project • Something you need to deploy and maintain your blog • See Github Pages, GitLab Pages and Jekyll
  • 4. Francesco Pira | fpira.com Why VCS? • A repository as a unique codebase • Reliability • History and changes + easy to roll back at any point • Blaming (who changed what?) • Side projects (aka forking a repo) • Parallel development on the same repo (aka team working) • Code deployment!
  • 5. Francesco Pira | fpira.com Popular VCS software ● Git ● Team Foundation Server (MS) ● Apache Subversion (SVN) ● Mercurial (BitBucket) ● Bazaar (Canonical) * In order of popularity
  • 6. Francesco Pira | fpira.com • repository = a directory with files (usually code!) • working tree = index of files part of the repo • ignoring = no to keep track of changes • staging = virtual area with changes ready to commit • commit = snapshot of a repository, changes saved in history • head = pointer to the latest commit of the current branch • branch = a copy of files to track different changes • merging = merging the history of a branch with his parent one • conflict = 2 or more people making changes to same file • tag = named pointer to a particular snapshot (e.g. v1.1.0) • remote = server (it can be another PC for distributed VCS) VCS concepts
  • 7. Francesco Pira | fpira.com Who’s Git? • Created by Linus Torvalds (mid 2005) • to manage the shared development of Linux kernel • Today is the most common VCS • It works using snapshots, pointers and compressed deltas • All changes and history are in ./.git • Works best with small files (see git lfs) • Distribute (remote) architecture • Used by GitHub: the biggest and de facto standard platform for sharing open-source code
  • 8. Francesco Pira | fpira.com Setup the environment ● Download and install git ○ bit.ly/linux-day-git-install ● Set it up ○ git config --global user.name "My Name" ○ git config --global user.email "my@email.com" ● Remotes require your to have an RSA key: set it up! ○ ssh-keygen -t rsa -b 4096 -C "my@email.com" ○ eval "$(ssh-agent -s)" ○ ssh-add ~/.ssh/id_rsa Pro tip: Use different RSA keys (personal, work, etc.)
  • 9. Francesco Pira | fpira.com Your first commit, yay! Locally on your computer • git init • git add . • git remote add origin ... • git commit -m “Hey! This is my first commit” • git push origin master Your teammate • git clone ...
  • 10. Francesco Pira | fpira.com Some notes master is the main and first branch origin is the primary remote. You push your code to it Tip: Use --global to make a setting work for all repo of current local user Interesting: Git global configuration usually lives here ~/.gitconfig or here ~/.config/git/config
  • 11. Francesco Pira | fpira.com Live demo
  • 12. Francesco Pira | fpira.com • init = initialise the repository (make ./.git subdir) • clone = make a local copy of the repo from a remote one • diff = show current changes (before staging them) • add = stage one of more file / folders • commit = make a ‘snapshot’ / save a state • branch = create a branch off the current one • merge = merge a branch into his parent • fetch = download (new) changes from remote • pull = fetch from remote branch + merge to local one • checkout = switch branch / restore file in working tree • reset = undo / remove from staging area • log = explore changes history • … tons of commands, each one has tons of parameters: RTFM! Main Git commands
  • 13. Francesco Pira | fpira.com Lazy as a pig? Aliases! git config --global alias.co checkout git config --global alias.br branch git config --global alias.ci commit git config --global alias.st 'status -s' git config --global alias.unstage 'reset HEAD --' ...Make yours!
  • 14. Francesco Pira | fpira.com Best practices • Don’t zip repositories! Use remotes! • master as the main branch • devel as the main development branch • all features start off devel • all features ends • usually you don’t push features • all releases must be tagged (in master) • use semantic versioning for tags • hotfix start off master, merged to master and devel
  • 15. Francesco Pira | fpira.com Credits to Vincent Driessen
  • 16. Francesco Pira | fpira.com Live demo
  • 17. Francesco Pira | fpira.com UI clients ● Windows and macOS ○ Sourcetree ● Linux ○ SmartGit
  • 18. Francesco Pira | fpira.com Best platforms ● GitHub ○ Free only for open-source public projects ● BitBucket ○ Free for unlimited private or public repos (any license) ○ Paid for 5+ collaborators ● GitLab ○ Paid enterprise version (with support) ○ Free Community Edition (self-hosted) ○ Free gitlab.com: unlimited repos, unlimited collaborators
  • 19. Francesco Pira | fpira.com Your turn! • Wow! git log --graph --oneline --decorate --all • Discover git stash and git pop • Deploy best practices • Use git-flow • Deploy a web application using git • Try git-lfs • ...Have fun!
  • 20. Francesco Pira | fpira.com Sources and extras • https://git-scm.com/book/en/v2/Getting-Started-Git-Basics • https://help.github.com/articles/generating-a-new-ssh-key-and-addi ng-it-to-the-ssh-agent/ • https://www.atlassian.com/git/tutorials • http://nvie.com/posts/a-successful-git-branching-model/ • http://semver.org (semantic versioning)
  • 21. Francesco Pira | fpira.com Thank you! Keep in touch fpira.com @pirafrank me@fpira.com github.com/ pirafrank