SlideShare ist ein Scribd-Unternehmen logo
1 von 67
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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 UseMediacurrent
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflowsArthur Shvetsov
 
Git Flow - An Introduction
Git Flow - An IntroductionGit Flow - An Introduction
Git Flow - An IntroductionKnoldus Inc.
 
An introduction to Git and GitFlow
An introduction to Git and GitFlowAn introduction to Git and GitFlow
An introduction to Git and GitFlowMark Everard
 
The gitflow way
The gitflow wayThe gitflow way
The gitflow wayRuijun 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 BranchesJavier Alvarez
 
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 TagsMikhail 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
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Gitgittower
 
19 GitFlow #burningkeyboards
19 GitFlow #burningkeyboards19 GitFlow #burningkeyboards
19 GitFlow #burningkeyboardsDenis Ristic
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 

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

Ähnlich wie Git with the flow

Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid 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 systemKumaresh Chandra Baruri
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - WorkflowTahsin 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 GitBADR
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshopthemystic_ca
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How tolanhuonga3
 
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
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git聖文 鄭
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
(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
 
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
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
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
 
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
 
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
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
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
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
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
 

Kürzlich hochgeladen (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
(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...
 
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...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
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 ...
 
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
 
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
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
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
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
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...
 

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)