SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Git Some Lernin
How To Git For Great Good
Why Version Control?
• Because I Say So.
Why Git?
• Because I Say So.
Vocabulary
• Repository -- Holds the history of all changes
• Commit -- A point in time snapshot of your repo
• Reference -- Something that makes it so you don't have to
remember a 40 hexadecimal digit sha1 hash
• Branch -- A pointer to the head of a group of commits
• Remote -- A thing you push to and pull from
• Pull Request -- How you get your code reviewed (unless you're on
kernel)
• Github -- Magic
Porcelain
1. Fork a project
2. Clone your fork
3. Branch
4. Edit some files
5. Commit
6. Repeat 4 and 5 until feature/bug is complete
7. REBASE to create a history that I won't mind reading through
8. Pull any changes that have happened on non-forked master in the interim and
rebase on top of those if you want a linear history otherwise do nothing for this step
9. Open pull request from your branch on your fork into the canonical repo's master
branch
10. Profit
How To Branch
• git checkout -b improvement/unicorns
• git branch bug/voldemort && git checkout bug/voldemort
How To Commit
• Edit Some Stuff
• git add -p and git add (DO NOT GIT ADD * or .)
• Review what is in staging with git diff --cached and
git status
• git commit
Commit Messages
• Start with bug number and short description <70
characters
• Longer description after one blank line
Index == Staging
• STAGE EVERYTHING
• Save time later by staging only some logical
changes now
Demo
Refs
• N^ goes up N parents (HEAD^, HEAD^100)
• ~ selects merge parents (HEAD~, HEAD~2)
• Mix and match (don't actually though)
• HEAD is hard coded and always points to the
current head of whatever branch you have
checked out
• Almost everything can be treated as a ref
Remotes
[remote "origin"]
url = git@github.com:ranman/fancy-project.git
fetch = +refs/heads/*:refs/remotes/origin/*
Everything is an object
(content addressable storage)
• Blob (zlib compressed bytes representing a file)
• Tree (a tree where the leaf nodes are blobs)
• Commit (a pointer to: a tree, n parent commits)
• Tag (a pointer to a commit)
• (IGNORE THIS) something something packfiles
You're just moving
some pointers around.
Dat Network
Fancy Random Things
Find Lost Stuff
• git reflog
• git fsck [--lost-found]
• git log -G
• git branch --contains SHA-1
Find Bugs
• git bisect
tig
git log branchA ^branchB
git log branchA..branchB
git log branchB..branchA
git log branchA...branchB
Undo
• git reset --soft HEAD^
• git reset --hard HEAD^
Config
• git config --global help.autocorrect 1
• git config --global rerere.enabled 1
• git config --global color.ui 1
• git diff --word-diff
gitshots
Git

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Talk to git
Talk to gitTalk to git
Talk to git
 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
 
Git-r-Done
Git-r-DoneGit-r-Done
Git-r-Done
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git-ing out of your git messes - Fluent Conf 2017
Git-ing out of  your git messes - Fluent Conf 2017Git-ing out of  your git messes - Fluent Conf 2017
Git-ing out of your git messes - Fluent Conf 2017
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Git 101
Git 101Git 101
Git 101
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
Git basic
Git basicGit basic
Git basic
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Git and fundamentals
Git and fundamentalsGit and fundamentals
Git and fundamentals
 
Git presentation
Git presentationGit presentation
Git presentation
 
Our ATLRUG.com Web Site
Our ATLRUG.com Web SiteOur ATLRUG.com Web Site
Our ATLRUG.com Web Site
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
Git
GitGit
Git
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
 
Git introduction workshop for scientists
Git introduction workshop for scientists Git introduction workshop for scientists
Git introduction workshop for scientists
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 

Andere mochten auch (7)

Schema Design in MongoDB - TriMug Meetup North Carolina
Schema Design in MongoDB - TriMug Meetup North CarolinaSchema Design in MongoDB - TriMug Meetup North Carolina
Schema Design in MongoDB - TriMug Meetup North Carolina
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
 
A Century Of Weather Data - Midwest.io
A Century Of Weather Data - Midwest.ioA Century Of Weather Data - Midwest.io
A Century Of Weather Data - Midwest.io
 
The 2008 battle of sadr city reimagining urban combat
The 2008 battle of sadr city reimagining urban combatThe 2008 battle of sadr city reimagining urban combat
The 2008 battle of sadr city reimagining urban combat
 
MongoDB at LAHacks :)
MongoDB at LAHacks :)MongoDB at LAHacks :)
MongoDB at LAHacks :)
 
Sharding in MongoDB Days 2013
Sharding in MongoDB Days 2013Sharding in MongoDB Days 2013
Sharding in MongoDB Days 2013
 
Canada DevOps Conference
Canada DevOps ConferenceCanada DevOps Conference
Canada DevOps Conference
 

Ähnlich wie Git

Ähnlich wie Git (20)

Gitlikeapro 2019
Gitlikeapro 2019Gitlikeapro 2019
Gitlikeapro 2019
 
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git Is A State Of Mind - The path to becoming a Master of the mystic art of GitGit Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git_new.pptx
Git_new.pptxGit_new.pptx
Git_new.pptx
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
Git uptospeed
Git uptospeedGit uptospeed
Git uptospeed
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Git
Git Git
Git
 
Git Educated About Git - 20 Essential Commands
Git Educated About Git - 20 Essential CommandsGit Educated About Git - 20 Essential Commands
Git Educated About Git - 20 Essential Commands
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Git hub for designers
Git hub for designersGit hub for designers
Git hub for designers
 
11 git version control
11 git version control11 git version control
11 git version control
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Learn Git form Beginners to Master
Learn Git form Beginners to MasterLearn Git form Beginners to Master
Learn Git form Beginners to Master
 
git and github
git and githubgit and github
git and github
 
Source control management
Source control managementSource control management
Source control management
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git 101
Git 101Git 101
Git 101
 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIs
 

Mehr von Randall Hunt

Mehr von Randall Hunt (7)

WhereML a Serverless ML Powered Location Guessing Twitter Bot
WhereML a Serverless ML Powered Location Guessing Twitter BotWhereML a Serverless ML Powered Location Guessing Twitter Bot
WhereML a Serverless ML Powered Location Guessing Twitter Bot
 
How to Choose The Right Database on AWS - Berlin Summit - 2019
How to Choose The Right Database on AWS - Berlin Summit - 2019How to Choose The Right Database on AWS - Berlin Summit - 2019
How to Choose The Right Database on AWS - Berlin Summit - 2019
 
Where ml ai_heavy
Where ml ai_heavyWhere ml ai_heavy
Where ml ai_heavy
 
Randall's re:Invent Recap
Randall's re:Invent RecapRandall's re:Invent Recap
Randall's re:Invent Recap
 
Deep Dive: AWS X-Ray London Summit 2017
Deep Dive: AWS X-Ray London Summit 2017Deep Dive: AWS X-Ray London Summit 2017
Deep Dive: AWS X-Ray London Summit 2017
 
TIAD - Is Automation Worth My Time?
TIAD - Is Automation Worth My Time?TIAD - Is Automation Worth My Time?
TIAD - Is Automation Worth My Time?
 
Replication MongoDB Days 2013
Replication MongoDB Days 2013Replication MongoDB Days 2013
Replication MongoDB Days 2013
 

Git

  • 1. Git Some Lernin How To Git For Great Good
  • 2. Why Version Control? • Because I Say So.
  • 4. Vocabulary • Repository -- Holds the history of all changes • Commit -- A point in time snapshot of your repo • Reference -- Something that makes it so you don't have to remember a 40 hexadecimal digit sha1 hash • Branch -- A pointer to the head of a group of commits • Remote -- A thing you push to and pull from • Pull Request -- How you get your code reviewed (unless you're on kernel) • Github -- Magic
  • 6. 1. Fork a project 2. Clone your fork 3. Branch 4. Edit some files 5. Commit 6. Repeat 4 and 5 until feature/bug is complete 7. REBASE to create a history that I won't mind reading through 8. Pull any changes that have happened on non-forked master in the interim and rebase on top of those if you want a linear history otherwise do nothing for this step 9. Open pull request from your branch on your fork into the canonical repo's master branch 10. Profit
  • 7. How To Branch • git checkout -b improvement/unicorns • git branch bug/voldemort && git checkout bug/voldemort
  • 8. How To Commit • Edit Some Stuff • git add -p and git add (DO NOT GIT ADD * or .) • Review what is in staging with git diff --cached and git status • git commit
  • 9. Commit Messages • Start with bug number and short description <70 characters • Longer description after one blank line
  • 10. Index == Staging • STAGE EVERYTHING • Save time later by staging only some logical changes now
  • 11. Demo
  • 12. Refs • N^ goes up N parents (HEAD^, HEAD^100) • ~ selects merge parents (HEAD~, HEAD~2) • Mix and match (don't actually though) • HEAD is hard coded and always points to the current head of whatever branch you have checked out • Almost everything can be treated as a ref
  • 13. Remotes [remote "origin"] url = git@github.com:ranman/fancy-project.git fetch = +refs/heads/*:refs/remotes/origin/*
  • 14. Everything is an object (content addressable storage)
  • 15. • Blob (zlib compressed bytes representing a file) • Tree (a tree where the leaf nodes are blobs) • Commit (a pointer to: a tree, n parent commits) • Tag (a pointer to a commit) • (IGNORE THIS) something something packfiles
  • 16.
  • 17.
  • 18.
  • 19. You're just moving some pointers around.
  • 21.
  • 22.
  • 24. Find Lost Stuff • git reflog • git fsck [--lost-found] • git log -G • git branch --contains SHA-1
  • 26. tig
  • 27. git log branchA ^branchB
  • 28. git log branchA..branchB git log branchB..branchA git log branchA...branchB
  • 29. Undo • git reset --soft HEAD^ • git reset --hard HEAD^
  • 30. Config • git config --global help.autocorrect 1 • git config --global rerere.enabled 1 • git config --global color.ui 1 • git diff --word-diff
  • 31.