SlideShare a Scribd company logo
Git with the Flow
By Dana White
Who is Dana White?
● This guy
Who is Dana?
● Coder
● Horse enthusiast
● Avid napper
● Contractor at
What is Git?
● Git is a version control system
What is a version control system?
● “Version control is a system that records changes to a file
or set of files over time so that you can recall specific
versions later.” - git-scm
● VCSs allow you to collaborate easily with other
developers, designers, etc
● VCSs allow you to blame others for issues in the code and
mock them
Why is Git different?
● Git is a Distributed Version Control System
● Git is not a Centralized Version Control System
Centralized Version Control System
● A single server has the full repository
● Clients check out latest snapshot
● Must be connected to server checkout and commit code
● SINGLE POINT OF FAILURE
● Popular (?) CVCSs: CVS, SVN
CVCS Diagram
Distributed Version Control System
● Each computer that connects has a full repository
● Commits can occur offline
● NO SINGLE POINT OF FAILURE...YAY!!!
● Popular DVCSs: Mercurial, GIT (the best)
DVCS Diagram
Gitting Started (with someone else’s repo)
● Clone an existing repo
● git clone https://github.com/d-co/wwc.git
How to git
● Write code
● Stage code
● Commit code
● Push Code
Gitting your code in there...
First... Then…
● git add <filename>
● git commit -m
● git push
Code
A quick word about “git add”
● The git add command stages a file for commit
● Adds and stages a previously un-revisioned file
● Stages a modified file for commit
● You could use git commit -a
○ but you’d be wrong
Back up! Know the changes BEFORE commit
git status
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: README.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
atextfile.txt
no changes added to commit (use "git add" and/or "git commit -a")
git status - new file
Untracked files:
(use "git add <file>..." to include in what
will be committed)
atextfile.txt
no changes added to commit (use "git add"
and/or "git commit -a")
git status - modified file
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in
working directory)
modified: README.md
What changed in that file? - git diff
diff --git a/README.md b/README.md
index bdfac6c..ddf9f4d 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
# wwc
This is a basic git repo!!
+Hello
git status - staged for commit
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: README.md
new file: atextfile.txt
Now let’s commit and push
● git commit -m “Added atextfile and said
hello!”
● git push
● NAP TIME!!!
Gitting changes from others
git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0),
pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/d-co/wwc
f4b4f69..b179149 master -> origin/master
Updating f4b4f69..b179149
Fast-forward
README.md | 3 +++
1 file changed, 3 insertions(+)
Wait a minute? What just happened?
git log
commit b17914988de7bc892faea78aea86e2889c53b419
Author: Dana <email@address.com>
Date: Sun Mar 19 23:22:55 2017 -0600
Update README.md
commit f4b4f69c4045438e0dc8ca5e1610d1fe4cd758f9
Author: Dana White <email@address.com>
Date: Sun Mar 19 23:21:17 2017 -0600
This is a commit and hello
Gitting started with your own repo
● git init
● git add README.md
● git commit -m “Your first commit”
● git remote add origin <your url>
● git push -u origin master
Add your git platform origin to git repo
● git init
● git add README.md
● git commit -m “Your first commit”
● git remote add origin <your url>
● git push -u origin master
Set the upstream for pushes
● git init
● git add README.md
● git commit -m “Your first commit”
● git remote add origin <your url>
● git push -u origin master
Branches
● Independent line of development
● Represents brand new dev, staging environment and
project history
● I stole this from
https://www.atlassian.com/git/tutorials/using-branches
Working on branches
● git checkout -b “branch-name”
● Do your work
● git checkout master
● git merge “branch-name”
And that’s all you need to know about git!!!
Provided nothing goes wrong….
Or you need to collaborate
Or maintain releases
Or just follow some best
practices so you’re not
constantly overwriting
what’s in production with no
way of easily going back
Git into trouble?
Something comes up
● Doing work
● Oh no, quick pivot!!
● Follow these steps
Pause work
● Doing work
● Oh no, quick pivot!!
● Follow these steps
● git stash
● git stash pop
Resume Work
● Doing work
● Oh no, quick pivot!!
● Follow these steps
● git stash
● git stash pop
Conflict
● Do some work
● Commit some work
● Git pull…..
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the
result.
Find that conflict
<<<<<<< HEAD
This IS a basic git repo!!
=======
This IS NOT a basic git repo!!
>>>>>>> 89892ec2b035f113fed2be257526dcf6a3603dbe
Fix that conflict
This IS a basic git repo!!
Mark as resolved and continue on
● git add <conflicted file>
● git commit
● git push
OH NO, Everything I did in this file is wrong
● git checkout <filename>
● Reverts all your changes in a given file
OH NO, Everything I did in this whole repo is wrong
● git reset --hard
● Reverts all your changes back to HEAD
OH NO, I forgot <insert thing> with that commit
● git commit --amend
● Allows you to add a file
● Change a commit message
● All around just fix what you forgot in the last commit
OH NO, Revert that commit
● git revert <commit>
● Creates a new commit
● Doesn’t overwrite history
● SAFE
OH NO, I need to kill everything about that
● git rebase/git rebase -i
● Re-writes history
● Use with CAUTION
● UNSAFE
Cases for Rebase
● Joe merged into master (again)
● Eliminate merge commits
● Squash unnecessary commits
Case Joe
● Joe pushed to default
● It is NOT production ready
● If we revert the commit, when we
go to merge it in, pain will ensue
● git rebase -i
● d <commit> “<message>”
● git push
--force-with-lease
Case Eliminate Merge Commits
A---B---C topic
/
D---E---F---G master
● Long running branch
that will need lots of
merges
● git rebase master
topic
A'--B'--C' topic
/
D---E---F---G master
Case Squash
● Do work
● A commit message like “Fixed
this problem”
● Another commit message like
“That didn’t work trying it again”
● “Shoot, another try”
● “Finally got it”
● git rebase -i
● s <commit> “<message>”
● git push
--force-with-lease
The Flow
What is Git Flow?
● A strategy for branching
● Creates an environment for independent, concurrent
development
● Maintains release branches and versions
The diagram
The branches
● master
● develop
● feature branches
● hotfix branches
● release branches
Master Branch
● Should mirror production
● Or be just about to be pushed to production
● Tagged with release numbers
Develop Branch
● Represents what’s currently be developed
● Branched from master
Feature Branches
● Represents a new feature
● Corresponds to one ticket in bug tracking (that’s just me)
● Typically worked on individually or by small team
● Branched off of develop
● Merged into develop
● Naming convention feature/<what’s-my-feature>
Hotfix branches
● Production emergency releases
● Outside of “normal” release
● Branched directly from master
● Merged back into master
● Naming convention: hotfix/<summary-of-hotfix>
Release branches
● The next batch of features to go into production
● Represents a sprint/cycle, whatever flow you’re using
● Branched off of develop
● Merges back into develop and master
● Naming convention: release/<version>
Why flow?
● Features are independent
● Master is always ready for a hotfix
● Allows for lots of different things with minimal toe-stepping
● Great for development with release cycles
Some Advanced Git
Git bisect -- Finding a broken commit
1. Find a commit where things are working
2. Find a commit where things aren’t working
3. Start git bisect
4. Git keeps finding middle point of a bisect and you tell it
what’s good and bad until you’ve traced it down
Git bisect - cont’d
● git bisect start
● git bisect good <commit>
● git bisect bad <commit>
● Mark each commit as good or bad until you find the first
bad commit
Git cherry-pick -- I just need that one thing
● There’s only one commit you need from a branch
● git cherry-pick <commit>
● Merge that one in
Gitignore
● Add a .gitignore file to your repo
● It tells git what to ignore when checking in
● Removes noise about un-revisioned IDE files
Git blame -- who screwed this up
● Traces file changes by username
● One of the few times I prefer a visual client
● git blame <filename>
Resources
Online repos
● BitBucket https://bitbucket.org/product
● GitHub https://github.com/
● Gitlab https://about.gitlab.com/
Git clients...why don’t you like command line???
● SourceTree https://www.sourcetreeapp.com/
● Tortoise (Windows) https://tortoisegit.org/
● Magit https://magit.vc/ -- I don’t know why you need a
client for Emacs, you should just suck it up and do
command line already
● Your IDE - probably
Git HELP!!!
● Git page https://git-scm.com/docs
● StackOverflow https://stackoverflow.com/
● The google (which will probably take you to one of the two
above)
Git with the flow

More Related Content

What's hot

DcATL 2013: Git-Flow for Daily Use
DcATL 2013: Git-Flow for Daily UseDcATL 2013: Git-Flow for Daily Use
DcATL 2013: Git-Flow for Daily Use
Mediacurrent
 
Git
GitGit
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
Git Flow - An Introduction
Git Flow - An IntroductionGit Flow - An Introduction
Git Flow - An Introduction
Knoldus Inc.
 
Git & gitflow
Git & gitflowGit & gitflow
Git & gitflow
Nolifelover Earn
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlow
Mark Everard
 
The gitflow way
The gitflow wayThe gitflow way
The gitflow way
Ruijun Li
 
Gitflow - Una metología para manejo de Branches
Gitflow - Una metología para manejo de BranchesGitflow - Una metología para manejo de Branches
Gitflow - Una metología para manejo de Branches
Javier Alvarez
 
Git Tricks
Git TricksGit Tricks
Git Tricks
Ivelina Dimova
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsGit Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and Tags
Mikhail Melnik
 
Why Aren't You Using Git Flow?
Why Aren't You Using Git Flow?Why Aren't You Using Git Flow?
Why Aren't You Using Git Flow?
John Congdon
 
Git presentation
Git presentationGit presentation
Git presentation
Sai Kumar Satapathy
 
Git flow
Git flowGit flow
Git flow
Valerio Como
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
Sergiu-Ioan Ungur
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Git
gittower
 
19 GitFlow #burningkeyboards
19 GitFlow #burningkeyboards19 GitFlow #burningkeyboards
19 GitFlow #burningkeyboards
Denis Ristic
 
Pubmi gitflow
Pubmi gitflowPubmi gitflow
Pubmi gitflow
Simone Gentili
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
Jim Yeh
 

What's hot (20)

DcATL 2013: Git-Flow for Daily Use
DcATL 2013: Git-Flow for Daily UseDcATL 2013: Git-Flow for Daily Use
DcATL 2013: Git-Flow for Daily Use
 
Git
GitGit
Git
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Git Flow - An Introduction
Git Flow - An IntroductionGit Flow - An Introduction
Git Flow - An Introduction
 
Git & gitflow
Git & gitflowGit & gitflow
Git & gitflow
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlow
 
The gitflow way
The gitflow wayThe gitflow way
The gitflow way
 
Git flow
Git flowGit flow
Git flow
 
Gitflow - Una metología para manejo de Branches
Gitflow - Una metología para manejo de BranchesGitflow - Una metología para manejo de Branches
Gitflow - Una metología para manejo de Branches
 
GIT - GOOD PRACTICES
GIT - GOOD PRACTICESGIT - GOOD PRACTICES
GIT - GOOD PRACTICES
 
Git Tricks
Git TricksGit Tricks
Git Tricks
 
Git Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and TagsGit Series. Episode 2. Merge, Upstream Commands and Tags
Git Series. Episode 2. Merge, Upstream Commands and Tags
 
Why Aren't You Using Git Flow?
Why Aren't You Using Git Flow?Why Aren't You Using Git Flow?
Why Aren't You Using Git Flow?
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git flow
Git flowGit flow
Git flow
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Git
 
19 GitFlow #burningkeyboards
19 GitFlow #burningkeyboards19 GitFlow #burningkeyboards
19 GitFlow #burningkeyboards
 
Pubmi gitflow
Pubmi gitflowPubmi gitflow
Pubmi gitflow
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 

Similar to Git with the flow

Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
seungzzang Kim
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
Aditya Tiwari
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
Aditya Tiwari
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Introduction to git, a version control system
Introduction to git, a version control systemIntroduction to git, a version control system
Introduction to git, a version control system
Kumaresh Chandra Baruri
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
Pablo Quiroga
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
Pablo Quiroga
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
GDSC UofT Mississauga
 
Git github
Git githubGit github
Git github
Anurag Deb
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
Tahsin Abrar
 
A Simple Introduction to Git
A Simple Introduction to GitA Simple Introduction to Git
A Simple Introduction to GitDaniel Tai
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
BADR
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
lanhuonga3
 
Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)
Ashok Kumar
 
3 Git
3 Git3 Git
Gn unify git
Gn unify gitGn unify git
Gn unify git
Priyanka Nag
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
聖文 鄭
 

Similar to Git with the flow (20)

Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Introduction to git, a version control system
Introduction to git, a version control systemIntroduction to git, a version control system
Introduction to git, a version control system
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
 
Demystifying Git
Demystifying GitDemystifying Git
Demystifying Git
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Git github
Git githubGit github
Git github
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
 
A Simple Introduction to Git
A Simple Introduction to GitA Simple Introduction to Git
A Simple Introduction to Git
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)Git Ninja KT (GitHub to GitLab)
Git Ninja KT (GitHub to GitLab)
 
3 Git
3 Git3 Git
3 Git
 
Gn unify git
Gn unify gitGn unify git
Gn unify git
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 

Recently uploaded

Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 

Recently uploaded (20)

Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 

Git with the flow

  • 1. Git with the Flow By Dana White
  • 2. Who is Dana White? ● This guy
  • 3. Who is Dana? ● Coder ● Horse enthusiast ● Avid napper ● Contractor at
  • 4. What is Git? ● Git is a version control system
  • 5. What is a version control system? ● “Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.” - git-scm ● VCSs allow you to collaborate easily with other developers, designers, etc ● VCSs allow you to blame others for issues in the code and mock them
  • 6. Why is Git different? ● Git is a Distributed Version Control System ● Git is not a Centralized Version Control System
  • 7. Centralized Version Control System ● A single server has the full repository ● Clients check out latest snapshot ● Must be connected to server checkout and commit code ● SINGLE POINT OF FAILURE ● Popular (?) CVCSs: CVS, SVN
  • 9. Distributed Version Control System ● Each computer that connects has a full repository ● Commits can occur offline ● NO SINGLE POINT OF FAILURE...YAY!!! ● Popular DVCSs: Mercurial, GIT (the best)
  • 11. Gitting Started (with someone else’s repo) ● Clone an existing repo ● git clone https://github.com/d-co/wwc.git
  • 12. How to git ● Write code ● Stage code ● Commit code ● Push Code
  • 13. Gitting your code in there... First... Then… ● git add <filename> ● git commit -m ● git push Code
  • 14. A quick word about “git add” ● The git add command stages a file for commit ● Adds and stages a previously un-revisioned file ● Stages a modified file for commit ● You could use git commit -a ○ but you’d be wrong
  • 15. Back up! Know the changes BEFORE commit git status Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: README.md Untracked files: (use "git add <file>..." to include in what will be committed) atextfile.txt no changes added to commit (use "git add" and/or "git commit -a")
  • 16. git status - new file Untracked files: (use "git add <file>..." to include in what will be committed) atextfile.txt no changes added to commit (use "git add" and/or "git commit -a")
  • 17. git status - modified file Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: README.md
  • 18. What changed in that file? - git diff diff --git a/README.md b/README.md index bdfac6c..ddf9f4d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ # wwc This is a basic git repo!! +Hello
  • 19. git status - staged for commit On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: README.md new file: atextfile.txt
  • 20. Now let’s commit and push ● git commit -m “Added atextfile and said hello!” ● git push ● NAP TIME!!!
  • 21. Gitting changes from others git pull remote: Counting objects: 3, done. remote: Compressing objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From https://github.com/d-co/wwc f4b4f69..b179149 master -> origin/master Updating f4b4f69..b179149 Fast-forward README.md | 3 +++ 1 file changed, 3 insertions(+)
  • 22. Wait a minute? What just happened? git log commit b17914988de7bc892faea78aea86e2889c53b419 Author: Dana <email@address.com> Date: Sun Mar 19 23:22:55 2017 -0600 Update README.md commit f4b4f69c4045438e0dc8ca5e1610d1fe4cd758f9 Author: Dana White <email@address.com> Date: Sun Mar 19 23:21:17 2017 -0600 This is a commit and hello
  • 23. Gitting started with your own repo ● git init ● git add README.md ● git commit -m “Your first commit” ● git remote add origin <your url> ● git push -u origin master
  • 24. Add your git platform origin to git repo ● git init ● git add README.md ● git commit -m “Your first commit” ● git remote add origin <your url> ● git push -u origin master
  • 25. Set the upstream for pushes ● git init ● git add README.md ● git commit -m “Your first commit” ● git remote add origin <your url> ● git push -u origin master
  • 26. Branches ● Independent line of development ● Represents brand new dev, staging environment and project history ● I stole this from https://www.atlassian.com/git/tutorials/using-branches
  • 27. Working on branches ● git checkout -b “branch-name” ● Do your work ● git checkout master ● git merge “branch-name”
  • 28. And that’s all you need to know about git!!!
  • 29. Provided nothing goes wrong…. Or you need to collaborate Or maintain releases Or just follow some best practices so you’re not constantly overwriting what’s in production with no way of easily going back
  • 31. Something comes up ● Doing work ● Oh no, quick pivot!! ● Follow these steps
  • 32. Pause work ● Doing work ● Oh no, quick pivot!! ● Follow these steps ● git stash ● git stash pop
  • 33. Resume Work ● Doing work ● Oh no, quick pivot!! ● Follow these steps ● git stash ● git stash pop
  • 34. Conflict ● Do some work ● Commit some work ● Git pull….. CONFLICT (content): Merge conflict in README.md Automatic merge failed; fix conflicts and then commit the result.
  • 35. Find that conflict <<<<<<< HEAD This IS a basic git repo!! ======= This IS NOT a basic git repo!! >>>>>>> 89892ec2b035f113fed2be257526dcf6a3603dbe
  • 36. Fix that conflict This IS a basic git repo!!
  • 37. Mark as resolved and continue on ● git add <conflicted file> ● git commit ● git push
  • 38. OH NO, Everything I did in this file is wrong ● git checkout <filename> ● Reverts all your changes in a given file
  • 39. OH NO, Everything I did in this whole repo is wrong ● git reset --hard ● Reverts all your changes back to HEAD
  • 40. OH NO, I forgot <insert thing> with that commit ● git commit --amend ● Allows you to add a file ● Change a commit message ● All around just fix what you forgot in the last commit
  • 41. OH NO, Revert that commit ● git revert <commit> ● Creates a new commit ● Doesn’t overwrite history ● SAFE
  • 42. OH NO, I need to kill everything about that ● git rebase/git rebase -i ● Re-writes history ● Use with CAUTION ● UNSAFE
  • 43. Cases for Rebase ● Joe merged into master (again) ● Eliminate merge commits ● Squash unnecessary commits
  • 44. Case Joe ● Joe pushed to default ● It is NOT production ready ● If we revert the commit, when we go to merge it in, pain will ensue ● git rebase -i ● d <commit> “<message>” ● git push --force-with-lease
  • 45. Case Eliminate Merge Commits A---B---C topic / D---E---F---G master ● Long running branch that will need lots of merges ● git rebase master topic A'--B'--C' topic / D---E---F---G master
  • 46. Case Squash ● Do work ● A commit message like “Fixed this problem” ● Another commit message like “That didn’t work trying it again” ● “Shoot, another try” ● “Finally got it” ● git rebase -i ● s <commit> “<message>” ● git push --force-with-lease
  • 48. What is Git Flow? ● A strategy for branching ● Creates an environment for independent, concurrent development ● Maintains release branches and versions
  • 50. The branches ● master ● develop ● feature branches ● hotfix branches ● release branches
  • 51. Master Branch ● Should mirror production ● Or be just about to be pushed to production ● Tagged with release numbers
  • 52. Develop Branch ● Represents what’s currently be developed ● Branched from master
  • 53. Feature Branches ● Represents a new feature ● Corresponds to one ticket in bug tracking (that’s just me) ● Typically worked on individually or by small team ● Branched off of develop ● Merged into develop ● Naming convention feature/<what’s-my-feature>
  • 54. Hotfix branches ● Production emergency releases ● Outside of “normal” release ● Branched directly from master ● Merged back into master ● Naming convention: hotfix/<summary-of-hotfix>
  • 55. Release branches ● The next batch of features to go into production ● Represents a sprint/cycle, whatever flow you’re using ● Branched off of develop ● Merges back into develop and master ● Naming convention: release/<version>
  • 56. Why flow? ● Features are independent ● Master is always ready for a hotfix ● Allows for lots of different things with minimal toe-stepping ● Great for development with release cycles
  • 58. Git bisect -- Finding a broken commit 1. Find a commit where things are working 2. Find a commit where things aren’t working 3. Start git bisect 4. Git keeps finding middle point of a bisect and you tell it what’s good and bad until you’ve traced it down
  • 59. Git bisect - cont’d ● git bisect start ● git bisect good <commit> ● git bisect bad <commit> ● Mark each commit as good or bad until you find the first bad commit
  • 60. Git cherry-pick -- I just need that one thing ● There’s only one commit you need from a branch ● git cherry-pick <commit> ● Merge that one in
  • 61. Gitignore ● Add a .gitignore file to your repo ● It tells git what to ignore when checking in ● Removes noise about un-revisioned IDE files
  • 62. Git blame -- who screwed this up ● Traces file changes by username ● One of the few times I prefer a visual client ● git blame <filename>
  • 64. Online repos ● BitBucket https://bitbucket.org/product ● GitHub https://github.com/ ● Gitlab https://about.gitlab.com/
  • 65. Git clients...why don’t you like command line??? ● SourceTree https://www.sourcetreeapp.com/ ● Tortoise (Windows) https://tortoisegit.org/ ● Magit https://magit.vc/ -- I don’t know why you need a client for Emacs, you should just suck it up and do command line already ● Your IDE - probably
  • 66. Git HELP!!! ● Git page https://git-scm.com/docs ● StackOverflow https://stackoverflow.com/ ● The google (which will probably take you to one of the two above)