SlideShare a Scribd company logo
1 of 74
Download to read offline
IS A STATE OF MIND
The path to becoming a Master of the mystic art of Git
Nicola Costantino
Do you know
GIT?
ThankYou!
Goodbye
Common Use
Git is a state of mind
img: Ā©Marvel
COMMON COMMANDS
ā€¢ Git status
ā€¢ Status of the repository
ā€¢ Git add <file,ā€¦>
ā€¢ Add file(s) to staging area
ā€¢ Under the hood:ā€œkeep an eye on itā€, prepare to recursively create tree and blob objects
ā€¢ Git commit [-m ā€œ<commitmessage>ā€]
ā€¢ Commit the changes added to the staging area
ā€¢ Under the hood:create the commit object,associate tree,blob and commit objects
ā€¢ Git pull
ā€¢ Pull the latest updates from the server
ā€¢ Git push
ā€¢ Push the commit(s) to the remote server
img: Ā©Marvel
Why deepen?
Git is a state of mindimg: Ā©Marvel
REAL LIFE
Source and real-life story
WHENYOUā€™LL KNOW
WHAT IT DOES AND HOW,
YOUā€™LL FIGURE OUT HOWTO USE IT
Git is a state of mind
Philosophy
Git is a state of mind
img: Ā©Marvel
GIT:WHAT
ā€¢ ā€œGit, the stupid content
trackerā€
ā€¢ API for DVCS
ā€¢ Created by LinusTorvalds in
2005 for Linux Kernel source
code
ā€¢ Before: patches & packages,
then proprietary BitKeeper
LinusTorvalds
Linusology
Home office
ā€œRespect should be earnedā€
To Nvidia, with love
and much, much moreā€¦
GIT
Linus about the name ā€œgitā€ (ā€œunpleasant personā€ in British English slang):
ā€œIā€™m an egotistical bastard,and I name all my projects after myself.Firstā€˜Linuxā€™,nowā€˜gitā€™.ā€ (source)
From the original README (source)
GOD MADE UNIVERSE IN 6 DAYS,
LINUS MADE GIT IN 4,
GIT SELF-HOSTED IN 1
ā€¢ Development start: ~April 3,2005
ā€¢ Announcement:April 6, 2005
ā€¢ Self-hosting:April 7, 2005
Original message from the mailing list
GOALS
ā€¢ Speed
ā€¢ Simple design
ā€¢ Strong support for non-linear development (thousands of
parallel branches)
ā€¢ Fully distributed
ā€¢ Able to handle large projects like the Linux kernel efficiently
(speed and data size)
COMMIT OFTEN
PERFECT LATER
PUBLISH ONCE
ā€¢ Commit early, commit often
ā€¢ Each commit represents one idea or one whole change (easier
to read or revert)
ā€¢ Each branch represents one feature (or topic) (easier to read or
merge)
ā€¢ Your local working directory,index and local repo are scratch
pads.
UnderTheHood
Git is a state of mind img: Ā©Marvel
WHY DEEPER?
ā€¢ Git originally designed and created for internal-aware pro
developers
ā€¢ Specific atomic commands,*NIX style
ā€¢ File-system alike level
ā€¢ Untold mantra:ā€œWhen youā€™ll know what it does and how,
youā€™ll figure out how to use itā€
LIFECYCLE
GIT GEOGRAPHY
ā€¢ Local repo: .git folder and its content
ā€¢ Working directory/area: brothers (and descendents)
of .git folder
ā€¢ Stage/Staging area/Cache/Index: (synonyms,index
originally) index of changes to commit
ā€¢ Stashing area/Stash: clipboard-ish area where to
temporarily save the changes not to be committed,
facility external toVCS
COMMANDS:
PORCELAIN VS.PLUMBING
PLUMBING(s)
Advanced, specific tools/commands for a single purpose and advanced problem
solving (Barely documented: are you a Pro, arenā€™tyou?)
PORCELAIN(s)
Different grouping and use of plumbing commands (Very extended documentation)
Git:API forDVCS
Avoid duplication of API with different parameters
Split underneath logics in simpler commands (UNIX-style)
OBJECTS
ā€¢ Main element in GIT:
ā€¢ Stored in key-value database: Key =>Value
ā€¢ Named after the content using SHA-1 hash:SHA-1(Value) => Value
ā€¢ IMMUTABLE: mutation would break hash, so references would be broken too!
ā€¢ Deduplication for free: same object referenced, not storedagain
ā€¢ Main object types:
ā€¢ Blob
ā€¢ Tree
ā€¢ Commit
ā€¢ AnnotatedTag
OBJECTS
ā€¢ Blob
ā€¢ Full content of a file without filename and metadata
ā€¢ Named after SHA-1 of content and attributes
ā€¢ Tree
ā€¢ Representation of a directory structure / file(s)
ā€¢ Recursive structure: contains blob and tree references
ā€¢ Commit
ā€¢ Snapshot of the repository at given time
ā€¢ Tree object reference (recursive)
ā€¢ Author's data:name,email,timestamp,timezone
ā€¢ Committer's data:name,email,timestamp,timezone
ā€¢ Commit Message
ā€¢ Parent commit reference (special commit: Merge commit has two/more than one parents)
.GIT FOLDER
ā€¢ Created with ā€˜git initā€™
command
ā€¢ The .git folder IS the local
repository
Structure of .git folder of an empty repository
.GIT FOLDER
ā€¢ After the commit of a
simple text file
Structure of .git folder of the repository at the current state
HEAD
ā€¢ It points to the current state
of the working area
ā€¢ Relative pointing to a refs,
e.g.:
ā€¢ ā€˜ref:refs/heads/masterā€™
ā€¢ In detached state if it points
to an hash
ā€¢ only good for read-only navigation of the
repo, destructive otherwise Structure of .git folder of the repository at the current state
CONFIG
ā€¢ Local configurations
ā€¢ Core configuration values
ā€¢ Authorā€™s data:
ā€¢ Name, email,ā€¦
ā€¢ Opposite to
global .gitconfig file in home
Structure of .git folder of the repository at the current state
.gitconfig
HOOKS
ā€¢ (Sample of) scripts
automatically launched in
response to a specific
events
ā€¢ Validation,styling rules,
commit checks,ā€¦
ā€¢ Without the .sample
Structure of .git folder of the repository at the current state
OBJECTS
ā€¢ Key-value database
ā€¢ Contains blobs, trees and
commits
ā€¢ 256 dirs max per level with
first 2 hex chars of object
hash (avoid filesystem
limits)
ā€¢ pack folder: highly compressed,
delta-optimized archives of
objects, created at push/pull Structure of .git folder of the repository at the current state
REFS
ā€¢ Heads == Branches
ā€¢ Tags (lightweight)
ā€¢ Refspec: specification of
references
ā€¢ Heads point to a specific
commit
ā€¢ Head of that branch
Structure of .git folder of the repository at the current state
BackTo Porcelain
Git is a state of mind
img: Ā©Marvel
LOG
ā€¢ Git log
ā€¢ Log of all commits in the common default format
ā€¢ More or less infinite combination of parameters for different
showing mode of the log (e.g.colors,graphic,relative time format:
n days ago)
ā€¢ Pretty format documentation
ā€¢ One of the longest man page!
ā€¢ If lost, use A DOG:git log --all --decorate --oneline --graph
FETCH VS.PULL
FETCH
ā€¢ Fetch refs (branches, tags) from
remote repository (one or more)
ā€¢ Doesnā€™t download commit
ā€¢ Useful for sync with new remote(s)
and/or branch(es)
PULL
ā€¢ Downloads commits
ā€¢ For the current branch from
remote counterpart
ā€¢ Doesnā€™t alter the state of the
working directory or local repository ā€¢ Automatically updates the
state of the working directory
ā€¢ git fetch && git merge FETCH_HEAD
BRANCHES
ā€¢ Extremely cheap and fast
ā€¢ A branch is a file that contains the reference to a commit.Thatā€™s it.
ā€¢ Itā€™s not an object, so (and thatā€™s why) itā€™s mutable!
ā€¢ The entire branch is recreated recursively using parent reference
of each commit, starting from the pointed one
ā€¢ Fast-forward merge if the branch starts from the end of original/
destination branch (e.g. after a rebase)
BRANCHING
ā€¢ Git checkout <branch>
ā€¢ Move to an existent branch
ā€¢ Git checkout -b <branch>
ā€¢ Create a branch if not existent and move to it
ā€¢ Git branch <branch>
ā€¢ Create a branch if not existent without moving to it
ā€¢ Git merge <branch>
ā€¢ Merge the specified branch on the current one
ā€¢ Git rebase <branch>
ā€¢ Rebase the current branch on the specified branch
STASHING
ā€¢ Git stash [save]
ā€¢ Save the changes in the working area into the stashing area
ā€¢ Git stash list
ā€¢ List all the stashes
ā€¢ Git stash show
ā€¢ Show the details of a stash
ā€¢ Git stash apply
ā€¢ Apply the specified stash on the current working directory
ā€¢ [other options and combinationā€¦]
TAGS
ā€¢ Simple name pointing to a
commit
ā€¢ Arbitrary fixed reference to a commit
ā€¢ 2 types (completely unrelated to each other)
Lightweight Annotated
ā€¢ Structurally similar to branch ā€¢ Structurally is an object
ā€¢ Simple name pointing to a
commit, with a message
TAGGING
ā€¢ Git tag
ā€¢ List all the tags
ā€¢ Git tag <tag name>
ā€¢ Create a lightweight tag on the current commit
ā€¢ Git tag -a <tag name> -m <message>
ā€¢ Create an annotated tag on the current commit, with the specified message
ā€¢ Git show <tag name>
ā€¢ Show details about the specified tag
ā€¢ Git push [remote] --tags
ā€¢ Push the tags on remote repository (Not pushed by default push command!)
BLAME
ā€¢ Useful for firing people
ā€¢ Shows the changes made on an object (list of
commits) with relative authors
ā€¢ Syntax:
ā€¢ git blame [lots of options] <file>
Advanced Use
Git is a state of mind
img: Ā©Marvel
REFLOG
ā€¢ Reference logs :)
ā€¢ git reflog [options]
ā€¢ ā€œRecord when the tips of branches and other references were updated
in the local repository.ā€(source)
ā€¢ ā€œIt saves yourā€¦ life!ā€ (anyone whoā€™ve usedit)
ā€¢ Commits are not deleted until the garbage collector comes in action!
ā€¢ Go back in time, locate the commit and restore
CHERRY-PICK
ā€¢ Apply the changes introduced by an existing commit
(somewhere in the repo)
ā€¢ It creates a new commit
ā€¢ Best results if the commit is atomic and self-
explanatory
ā€¢ git cherry-pick <commit>
REBASE
ā€¢ Reapply commits on top of another base tip
ā€¢ Interactive rebase with -i option (options in text editor)
ā€¢ Main uses:
ā€¢ History rewriting,actions (edit,squash,delete,ā€¦) on the same base:git rebase
<commit>
ā€¢ Branch update, git rebase <branch>:
ā€¢ B branched from A at commit C1,A updated after the divergence (commits C2,C3)
ā€¢ Rebase B on top of new tip of A (C3) reapplying all the commits of B on top of C3
ā€¢ Best results if the commit is atomic and self-explanatory
Starting fromā€¦
Adding on Masterā€¦
More on Masterā€¦
Not elegant, but not so badā€¦
What ifā€¦
ā€œBOOM, Baby!ā€
Ā«You can call me Base,
Re-Base!Ā»
BISECT
ā€¢ Use binary search to find the commit that introduced a bug
ā€¢ Automatic mode usage:
ā€¢ Select known good commit: git bisect good <commitā€™s sha-1>
ā€¢ Select known bad commit: git bisect bad <commitā€™s sha-1>
ā€¢ Run the test in commits betweenā€œgoodā€andā€œbadā€:git bisect run <bash
script>
ā€¢ Bisect will stop at the first commit that introduced the bug (test fails)
ā€¢ More info
Modularity
Git is a state of mind
img: Ā©Marvel
SUBMODULE
ā€¢ Include a git repository inside another one
ā€¢ Both stories remain separated
ā€¢ Push/pull, branches to/from original separate repository
ā€¢ .gitmodule
ā€¢ Reference to submodule(s)ā€™s repository
ā€¢ Reference to submodule(s)ā€™s current commit (HEAD)
ā€¢ Reference to submodule(s)ā€™s destination directory (added empty to parent
repository)
SUBMODULE COMMANDS
ā€¢ Git submodule add <repository> [path]
ā€¢ Add an existing repository as submodule in path or subrepo name if any
ā€¢ Git submodule foreachā€˜<bash>ā€™
ā€¢ Execute the command specified for each submodule added in the parent repository
ā€¢ Git submodule update [path]
ā€¢ Update the submodule to the state specified into .gitmodule file (potentially discard
new changes)
ā€¢ (Canonical add, commit to update the .gitmodule file with newest
submodule commits)
SUBTREE
ā€¢ Include a git repository inside another one
ā€¢ Stories are not separated: the subtreeā€™s story is included in parent
repository (can be squashed)
ā€¢ Modification to subtreeā€™s code goes on parent projectā€™s
repository
ā€¢ Can pull updates from original repository
ā€¢ Can push updates to original repository
SUBTREE COMMANDS
ā€¢ Git subtree add --prefix=[path] <repository> <branch> --squash
ā€¢ Add an existing repository as subtree in path squashing all the commits in one
ā€¢ Git subtree pull --prefix [path] <repository> <branch> --squash
ā€¢ Update the subtree with new commits on remote repository
ā€¢ Contribute back to remote repository:
ā€¢ Add the project as another remote: git remote add <name> <repo>
ā€¢ git subtree push ā€”prefix=<prefix> <remote> <branch>
ā€¢ More info about subtree: Source,Source
Workflows
Git is a state of mind
img: Ā©Marvel
GITFLOW
Source, from GitHub
My 2 centsā€¦
ā€¢ Commit ASAP, usingVERY crystal clear message
ā€¢ Rebase your local branch without fear until it goes on remote
ā€¢ Keep the history straight! Avoid branch updating with merge!
ā€¢ Keep environment configuration - e.g. production - on specific
branch (to be rebased on the branch that will go online)
ā€¢ Use git aliases, but remember the original command
ā€¢ The current status and branch must be always visible without
issuing ā€œgit statusā€ (e.g. use things like bash-git-prompt or similar)
ā€¢ Fetch is better than pull for crowded branches
Ecosystem
Git is a state of mind
img: Ā©Marvel
BITBUCKET
More than 1 million teams and 6 million developers,Git/Mercurial
Homepage
GITHUB
Homepage
GITHUB
ā€¢ Biggest community exclusively for git ecosystem
ā€¢ 316 programming languages, ~6M active users, ~332K activeorganizations,
~19.5M active repositories
ā€¢ Main home for any open source project (hosted for free withTravisCI)
ā€¢ Most advanced web interface and support for most diffused and evolved
development metodologies at any level (Agile,Testing, CI/CD,ā€¦)
ā€¢ Highly reliable, but not self-hostable
ā€¢ The annual state of the Octoverse
GITLAB
Homepage
GITLAB
ā€¢ Fastest development project and community exclusively for git ecosystem: rolling releases and CI
ā€¢ More than 100K active organizations self-hosting (2/3 market), ~80% of mobile developers
repositories
ā€¢ Self-hostable (Vagrant, Docker, native), free public and private repositories with unlimitedmembers
ā€¢ Awesome repository management (user permissions,branch protection,Webhooks,ā€¦)
ā€¢ Most advanced web interface and support for most diffused and evolved development
metodologies at any level (Agile,Testing, CI/CD,ā€¦)
ā€¢ Most experimental and cutting-edge solutions for Agile and DevOps metodologies development
(Auto DevOps,ā€¦)
ā€¢ Full stack of additional features (pages,CI/CD,Cycle,IssueTracker and Board,Review,ā€¦)
Demo
Git is a state of mind
img: Ā©Marvel
Extras
Git is a state of mind
img: Ā©Marvel
EXTRA
ā€¢ ā€œGitHub cheatsheetā€ - Official basic GitHub cheatsheet
ā€¢ ā€œVisual cheatsheetā€ - Interactive cheatsheet
ā€¢ ā€œUngitā€ - Interactive web interface
ā€¢ ā€œGourceā€ - Repo visualization
ā€¢ ā€œGitKrakenā€ - GUI tool
ā€¢ ā€œGitHub Desktopā€ - Official GitHub GUI tool
References,Resources,
License
Git is a state of mind
img: Ā©Marvel
REFERENCES / RESOURCES
Conferences
ā€œGit From the Bits Upā€ -Tim Berglund
ā€œAdvanced GIT for Developersā€ - Lorna Jane Mitchell
ā€œGet Started with Gitā€ - DavidBaumgold
ā€œAdvanced Gitā€ - DavidBaumgold
ā€œA journey intoā€ GIT internals with Python - AndreySyschikov
Books
Pro Git
ā€œGit Best Practices Guideā€ - Eric Pidoux
ā€œMastering Gitā€ - Jakub Narębski
ā€œLearn enough Git to be dangerousā€ - MichaelHartl
LICENSE
ā€¢ The whole presentation and the entire content (except where alternatively
and explicitly specified) is property of the author, Nicola Costantino, and itā€™s
released under the term of the ā€œCreative CommonsAttribution -
NonCommercial - NoDerivatives 4.0 International Licenseā€
ā€¢ All third party media contents are property of their respective owners and
are hereby only used for teaching purposes
You better learn itā€¦
Source:Youtube
ThankYou!
Git is a state of mind
img: Ā©Marvel
Nicola Costantino
ā€¢ nicolacostantino.com
ā€¢ Twitter: https://twitter.com/theroadtodark
ā€¢ Medium: https://medium.com/
@theroadtodarkness
ā€¢ GitHub: https://github.com/NicolaCostantino
ā€¢ Linkedin: https://www.linkedin.com/in/
nicolacostantino/
About (Work In Progress) meā€¦

More Related Content

What's hot

Git: from Novice to Expert
Git: from Novice to ExpertGit: from Novice to Expert
Git: from Novice to ExpertGoddy Zhao
Ā 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Gitatishgoswami
Ā 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of troubleJon Senchyna
Ā 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshellPranesh Vittal
Ā 
Apache development with GitHub and Travis CI
Apache development with GitHub and Travis CIApache development with GitHub and Travis CI
Apache development with GitHub and Travis CIJukka Zitting
Ā 
Git Terminologies
Git TerminologiesGit Terminologies
Git TerminologiesYash
Ā 
Git training v10
Git training v10Git training v10
Git training v10Skander Hamza
Ā 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of GitDivineOmega
Ā 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messesKatie Sylor-Miller
Ā 
Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From GitChris Miller
Ā 
January OpenNTF Webinar - Backup your Domino Server - New Options in V12
January OpenNTF Webinar - Backup your Domino Server - New Options in V12January OpenNTF Webinar - Backup your Domino Server - New Options in V12
January OpenNTF Webinar - Backup your Domino Server - New Options in V12Howard Greenberg
Ā 
Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...SlideTeam
Ā 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial IIJim Yeh
Ā 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners Anurag Upadhaya
Ā 
April, 2021 OpenNTF Webinar - Domino Administration Best Practices
April, 2021 OpenNTF Webinar - Domino Administration Best PracticesApril, 2021 OpenNTF Webinar - Domino Administration Best Practices
April, 2021 OpenNTF Webinar - Domino Administration Best PracticesHoward Greenberg
Ā 
Source control management
Source control managementSource control management
Source control managementOwen Winkler
Ā 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshellalignan
Ā 
Git presentation to some coworkers some time ago
Git presentation to some coworkers some time agoGit presentation to some coworkers some time ago
Git presentation to some coworkers some time agoRodrigo Urubatan
Ā 

What's hot (20)

Git: from Novice to Expert
Git: from Novice to ExpertGit: from Novice to Expert
Git: from Novice to Expert
Ā 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Ā 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
Ā 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
Ā 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
Ā 
Apache development with GitHub and Travis CI
Apache development with GitHub and Travis CIApache development with GitHub and Travis CI
Apache development with GitHub and Travis CI
Ā 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
Ā 
Git training v10
Git training v10Git training v10
Git training v10
Ā 
The Fundamentals of Git
The Fundamentals of GitThe Fundamentals of Git
The Fundamentals of Git
Ā 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
Ā 
Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From Git
Ā 
January OpenNTF Webinar - Backup your Domino Server - New Options in V12
January OpenNTF Webinar - Backup your Domino Server - New Options in V12January OpenNTF Webinar - Backup your Domino Server - New Options in V12
January OpenNTF Webinar - Backup your Domino Server - New Options in V12
Ā 
Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...Introduction To Git For Version Control Architecture And Common Commands Comp...
Introduction To Git For Version Control Architecture And Common Commands Comp...
Ā 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial II
Ā 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
Ā 
April, 2021 OpenNTF Webinar - Domino Administration Best Practices
April, 2021 OpenNTF Webinar - Domino Administration Best PracticesApril, 2021 OpenNTF Webinar - Domino Administration Best Practices
April, 2021 OpenNTF Webinar - Domino Administration Best Practices
Ā 
3 Git
3 Git3 Git
3 Git
Ā 
Source control management
Source control managementSource control management
Source control management
Ā 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
Ā 
Git presentation to some coworkers some time ago
Git presentation to some coworkers some time agoGit presentation to some coworkers some time ago
Git presentation to some coworkers some time ago
Ā 

Similar to Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git

Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)Ahmed El-Arabawy
Ā 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)Salvatore Cordiano
Ā 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsGorav Singal
Ā 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthroughBimal Jain
Ā 
Git tips and tricks
Git   tips and tricksGit   tips and tricks
Git tips and tricksChris Ballance
Ā 
Git.From thorns to the stars
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the starsStrannik_2013
Ā 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
Ā 
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 GitHubBigBlueHat
Ā 
Git for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIsTim Osborn
Ā 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
Ā 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitRobert Lee-Cann
Ā 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITPouriaQashqai1
Ā 
Git basic commands
Git basic commandsGit basic commands
Git basic commandsAdarsh Konchady
Ā 

Similar to Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git (20)

Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Embedded Systems: Lecture 11: Introduction to Git & GitHub (Part 2)
Ā 
Git 101
Git 101Git 101
Git 101
Ā 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
Ā 
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levelsLearn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levels
Ā 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Ā 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
Ā 
Git tips and tricks
Git   tips and tricksGit   tips and tricks
Git tips and tricks
Ā 
Git.From thorns to the stars
Git.From thorns to the starsGit.From thorns to the stars
Git.From thorns to the stars
Ā 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
Ā 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Ā 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
Ā 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Ā 
Git_new.pptx
Git_new.pptxGit_new.pptx
Git_new.pptx
Ā 
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 for folk who like GUIs
Git for folk who like GUIsGit for folk who like GUIs
Git for folk who like GUIs
Ā 
Git Real
Git RealGit Real
Git Real
Ā 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Ā 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
Ā 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GIT
Ā 
Git basic commands
Git basic commandsGit basic commands
Git basic commands
Ā 

Recently uploaded

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
Ā 
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
Ā 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
Ā 
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfGOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfAlina Yurenko
Ā 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
Ā 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
Ā 
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
Ā 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
Ā 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
Ā 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
Ā 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
Ā 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
Ā 
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·åŠžē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·umasea
Ā 
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024StefanoLambiase
Ā 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
Ā 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
Ā 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
Ā 

Recently uploaded (20)

Hot Sexy call girls in Patel NagaršŸ” 9953056974 šŸ” escort Service
Hot Sexy call girls in Patel NagaršŸ” 9953056974 šŸ” escort ServiceHot Sexy call girls in Patel NagaršŸ” 9953056974 šŸ” escort Service
Hot Sexy call girls in Patel NagaršŸ” 9953056974 šŸ” escort Service
Ā 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
Ā 
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...
Ā 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
Ā 
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfGOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
Ā 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Ā 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
Ā 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Ā 
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)
Ā 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Ā 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
Ā 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
Ā 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Ā 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Ā 
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·åŠžē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
办ē†å­¦ä½čƁ(UQę–‡å‡­čƁ书)ę˜†å£«å…°å¤§å­¦ęƕäøščÆęˆē»©å•åŽŸē‰ˆäø€ęØ”äø€ę ·
Ā 
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Ā 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
Ā 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
Ā 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
Ā 

Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git

  • 1. IS A STATE OF MIND The path to becoming a Master of the mystic art of Git Nicola Costantino
  • 4. Common Use Git is a state of mind img: Ā©Marvel
  • 5. COMMON COMMANDS ā€¢ Git status ā€¢ Status of the repository ā€¢ Git add <file,ā€¦> ā€¢ Add file(s) to staging area ā€¢ Under the hood:ā€œkeep an eye on itā€, prepare to recursively create tree and blob objects ā€¢ Git commit [-m ā€œ<commitmessage>ā€] ā€¢ Commit the changes added to the staging area ā€¢ Under the hood:create the commit object,associate tree,blob and commit objects ā€¢ Git pull ā€¢ Pull the latest updates from the server ā€¢ Git push ā€¢ Push the commit(s) to the remote server
  • 6. img: Ā©Marvel Why deepen? Git is a state of mindimg: Ā©Marvel
  • 7. REAL LIFE Source and real-life story
  • 8. WHENYOUā€™LL KNOW WHAT IT DOES AND HOW, YOUā€™LL FIGURE OUT HOWTO USE IT Git is a state of mind
  • 9. Philosophy Git is a state of mind img: Ā©Marvel
  • 10. GIT:WHAT ā€¢ ā€œGit, the stupid content trackerā€ ā€¢ API for DVCS ā€¢ Created by LinusTorvalds in 2005 for Linux Kernel source code ā€¢ Before: patches & packages, then proprietary BitKeeper LinusTorvalds
  • 11. Linusology Home office ā€œRespect should be earnedā€ To Nvidia, with love and much, much moreā€¦
  • 12. GIT Linus about the name ā€œgitā€ (ā€œunpleasant personā€ in British English slang): ā€œIā€™m an egotistical bastard,and I name all my projects after myself.Firstā€˜Linuxā€™,nowā€˜gitā€™.ā€ (source) From the original README (source)
  • 13. GOD MADE UNIVERSE IN 6 DAYS, LINUS MADE GIT IN 4, GIT SELF-HOSTED IN 1 ā€¢ Development start: ~April 3,2005 ā€¢ Announcement:April 6, 2005 ā€¢ Self-hosting:April 7, 2005 Original message from the mailing list
  • 14. GOALS ā€¢ Speed ā€¢ Simple design ā€¢ Strong support for non-linear development (thousands of parallel branches) ā€¢ Fully distributed ā€¢ Able to handle large projects like the Linux kernel efficiently (speed and data size)
  • 15. COMMIT OFTEN PERFECT LATER PUBLISH ONCE ā€¢ Commit early, commit often ā€¢ Each commit represents one idea or one whole change (easier to read or revert) ā€¢ Each branch represents one feature (or topic) (easier to read or merge) ā€¢ Your local working directory,index and local repo are scratch pads.
  • 16. UnderTheHood Git is a state of mind img: Ā©Marvel
  • 17. WHY DEEPER? ā€¢ Git originally designed and created for internal-aware pro developers ā€¢ Specific atomic commands,*NIX style ā€¢ File-system alike level ā€¢ Untold mantra:ā€œWhen youā€™ll know what it does and how, youā€™ll figure out how to use itā€
  • 19. GIT GEOGRAPHY ā€¢ Local repo: .git folder and its content ā€¢ Working directory/area: brothers (and descendents) of .git folder ā€¢ Stage/Staging area/Cache/Index: (synonyms,index originally) index of changes to commit ā€¢ Stashing area/Stash: clipboard-ish area where to temporarily save the changes not to be committed, facility external toVCS
  • 20. COMMANDS: PORCELAIN VS.PLUMBING PLUMBING(s) Advanced, specific tools/commands for a single purpose and advanced problem solving (Barely documented: are you a Pro, arenā€™tyou?) PORCELAIN(s) Different grouping and use of plumbing commands (Very extended documentation) Git:API forDVCS Avoid duplication of API with different parameters Split underneath logics in simpler commands (UNIX-style)
  • 21. OBJECTS ā€¢ Main element in GIT: ā€¢ Stored in key-value database: Key =>Value ā€¢ Named after the content using SHA-1 hash:SHA-1(Value) => Value ā€¢ IMMUTABLE: mutation would break hash, so references would be broken too! ā€¢ Deduplication for free: same object referenced, not storedagain ā€¢ Main object types: ā€¢ Blob ā€¢ Tree ā€¢ Commit ā€¢ AnnotatedTag
  • 22. OBJECTS ā€¢ Blob ā€¢ Full content of a file without filename and metadata ā€¢ Named after SHA-1 of content and attributes ā€¢ Tree ā€¢ Representation of a directory structure / file(s) ā€¢ Recursive structure: contains blob and tree references ā€¢ Commit ā€¢ Snapshot of the repository at given time ā€¢ Tree object reference (recursive) ā€¢ Author's data:name,email,timestamp,timezone ā€¢ Committer's data:name,email,timestamp,timezone ā€¢ Commit Message ā€¢ Parent commit reference (special commit: Merge commit has two/more than one parents)
  • 23. .GIT FOLDER ā€¢ Created with ā€˜git initā€™ command ā€¢ The .git folder IS the local repository Structure of .git folder of an empty repository
  • 24. .GIT FOLDER ā€¢ After the commit of a simple text file Structure of .git folder of the repository at the current state
  • 25. HEAD ā€¢ It points to the current state of the working area ā€¢ Relative pointing to a refs, e.g.: ā€¢ ā€˜ref:refs/heads/masterā€™ ā€¢ In detached state if it points to an hash ā€¢ only good for read-only navigation of the repo, destructive otherwise Structure of .git folder of the repository at the current state
  • 26. CONFIG ā€¢ Local configurations ā€¢ Core configuration values ā€¢ Authorā€™s data: ā€¢ Name, email,ā€¦ ā€¢ Opposite to global .gitconfig file in home Structure of .git folder of the repository at the current state
  • 28. HOOKS ā€¢ (Sample of) scripts automatically launched in response to a specific events ā€¢ Validation,styling rules, commit checks,ā€¦ ā€¢ Without the .sample Structure of .git folder of the repository at the current state
  • 29. OBJECTS ā€¢ Key-value database ā€¢ Contains blobs, trees and commits ā€¢ 256 dirs max per level with first 2 hex chars of object hash (avoid filesystem limits) ā€¢ pack folder: highly compressed, delta-optimized archives of objects, created at push/pull Structure of .git folder of the repository at the current state
  • 30. REFS ā€¢ Heads == Branches ā€¢ Tags (lightweight) ā€¢ Refspec: specification of references ā€¢ Heads point to a specific commit ā€¢ Head of that branch Structure of .git folder of the repository at the current state
  • 31. BackTo Porcelain Git is a state of mind img: Ā©Marvel
  • 32. LOG ā€¢ Git log ā€¢ Log of all commits in the common default format ā€¢ More or less infinite combination of parameters for different showing mode of the log (e.g.colors,graphic,relative time format: n days ago) ā€¢ Pretty format documentation ā€¢ One of the longest man page! ā€¢ If lost, use A DOG:git log --all --decorate --oneline --graph
  • 33. FETCH VS.PULL FETCH ā€¢ Fetch refs (branches, tags) from remote repository (one or more) ā€¢ Doesnā€™t download commit ā€¢ Useful for sync with new remote(s) and/or branch(es) PULL ā€¢ Downloads commits ā€¢ For the current branch from remote counterpart ā€¢ Doesnā€™t alter the state of the working directory or local repository ā€¢ Automatically updates the state of the working directory ā€¢ git fetch && git merge FETCH_HEAD
  • 34. BRANCHES ā€¢ Extremely cheap and fast ā€¢ A branch is a file that contains the reference to a commit.Thatā€™s it. ā€¢ Itā€™s not an object, so (and thatā€™s why) itā€™s mutable! ā€¢ The entire branch is recreated recursively using parent reference of each commit, starting from the pointed one ā€¢ Fast-forward merge if the branch starts from the end of original/ destination branch (e.g. after a rebase)
  • 35. BRANCHING ā€¢ Git checkout <branch> ā€¢ Move to an existent branch ā€¢ Git checkout -b <branch> ā€¢ Create a branch if not existent and move to it ā€¢ Git branch <branch> ā€¢ Create a branch if not existent without moving to it ā€¢ Git merge <branch> ā€¢ Merge the specified branch on the current one ā€¢ Git rebase <branch> ā€¢ Rebase the current branch on the specified branch
  • 36. STASHING ā€¢ Git stash [save] ā€¢ Save the changes in the working area into the stashing area ā€¢ Git stash list ā€¢ List all the stashes ā€¢ Git stash show ā€¢ Show the details of a stash ā€¢ Git stash apply ā€¢ Apply the specified stash on the current working directory ā€¢ [other options and combinationā€¦]
  • 37. TAGS ā€¢ Simple name pointing to a commit ā€¢ Arbitrary fixed reference to a commit ā€¢ 2 types (completely unrelated to each other) Lightweight Annotated ā€¢ Structurally similar to branch ā€¢ Structurally is an object ā€¢ Simple name pointing to a commit, with a message
  • 38. TAGGING ā€¢ Git tag ā€¢ List all the tags ā€¢ Git tag <tag name> ā€¢ Create a lightweight tag on the current commit ā€¢ Git tag -a <tag name> -m <message> ā€¢ Create an annotated tag on the current commit, with the specified message ā€¢ Git show <tag name> ā€¢ Show details about the specified tag ā€¢ Git push [remote] --tags ā€¢ Push the tags on remote repository (Not pushed by default push command!)
  • 39. BLAME ā€¢ Useful for firing people ā€¢ Shows the changes made on an object (list of commits) with relative authors ā€¢ Syntax: ā€¢ git blame [lots of options] <file>
  • 40. Advanced Use Git is a state of mind img: Ā©Marvel
  • 41. REFLOG ā€¢ Reference logs :) ā€¢ git reflog [options] ā€¢ ā€œRecord when the tips of branches and other references were updated in the local repository.ā€(source) ā€¢ ā€œIt saves yourā€¦ life!ā€ (anyone whoā€™ve usedit) ā€¢ Commits are not deleted until the garbage collector comes in action! ā€¢ Go back in time, locate the commit and restore
  • 42. CHERRY-PICK ā€¢ Apply the changes introduced by an existing commit (somewhere in the repo) ā€¢ It creates a new commit ā€¢ Best results if the commit is atomic and self- explanatory ā€¢ git cherry-pick <commit>
  • 43. REBASE ā€¢ Reapply commits on top of another base tip ā€¢ Interactive rebase with -i option (options in text editor) ā€¢ Main uses: ā€¢ History rewriting,actions (edit,squash,delete,ā€¦) on the same base:git rebase <commit> ā€¢ Branch update, git rebase <branch>: ā€¢ B branched from A at commit C1,A updated after the divergence (commits C2,C3) ā€¢ Rebase B on top of new tip of A (C3) reapplying all the commits of B on top of C3 ā€¢ Best results if the commit is atomic and self-explanatory
  • 47. Not elegant, but not so badā€¦
  • 50. Ā«You can call me Base, Re-Base!Ā»
  • 51. BISECT ā€¢ Use binary search to find the commit that introduced a bug ā€¢ Automatic mode usage: ā€¢ Select known good commit: git bisect good <commitā€™s sha-1> ā€¢ Select known bad commit: git bisect bad <commitā€™s sha-1> ā€¢ Run the test in commits betweenā€œgoodā€andā€œbadā€:git bisect run <bash script> ā€¢ Bisect will stop at the first commit that introduced the bug (test fails) ā€¢ More info
  • 52. Modularity Git is a state of mind img: Ā©Marvel
  • 53. SUBMODULE ā€¢ Include a git repository inside another one ā€¢ Both stories remain separated ā€¢ Push/pull, branches to/from original separate repository ā€¢ .gitmodule ā€¢ Reference to submodule(s)ā€™s repository ā€¢ Reference to submodule(s)ā€™s current commit (HEAD) ā€¢ Reference to submodule(s)ā€™s destination directory (added empty to parent repository)
  • 54. SUBMODULE COMMANDS ā€¢ Git submodule add <repository> [path] ā€¢ Add an existing repository as submodule in path or subrepo name if any ā€¢ Git submodule foreachā€˜<bash>ā€™ ā€¢ Execute the command specified for each submodule added in the parent repository ā€¢ Git submodule update [path] ā€¢ Update the submodule to the state specified into .gitmodule file (potentially discard new changes) ā€¢ (Canonical add, commit to update the .gitmodule file with newest submodule commits)
  • 55. SUBTREE ā€¢ Include a git repository inside another one ā€¢ Stories are not separated: the subtreeā€™s story is included in parent repository (can be squashed) ā€¢ Modification to subtreeā€™s code goes on parent projectā€™s repository ā€¢ Can pull updates from original repository ā€¢ Can push updates to original repository
  • 56. SUBTREE COMMANDS ā€¢ Git subtree add --prefix=[path] <repository> <branch> --squash ā€¢ Add an existing repository as subtree in path squashing all the commits in one ā€¢ Git subtree pull --prefix [path] <repository> <branch> --squash ā€¢ Update the subtree with new commits on remote repository ā€¢ Contribute back to remote repository: ā€¢ Add the project as another remote: git remote add <name> <repo> ā€¢ git subtree push ā€”prefix=<prefix> <remote> <branch> ā€¢ More info about subtree: Source,Source
  • 57. Workflows Git is a state of mind img: Ā©Marvel
  • 59. My 2 centsā€¦ ā€¢ Commit ASAP, usingVERY crystal clear message ā€¢ Rebase your local branch without fear until it goes on remote ā€¢ Keep the history straight! Avoid branch updating with merge! ā€¢ Keep environment configuration - e.g. production - on specific branch (to be rebased on the branch that will go online) ā€¢ Use git aliases, but remember the original command ā€¢ The current status and branch must be always visible without issuing ā€œgit statusā€ (e.g. use things like bash-git-prompt or similar) ā€¢ Fetch is better than pull for crowded branches
  • 60. Ecosystem Git is a state of mind img: Ā©Marvel
  • 61. BITBUCKET More than 1 million teams and 6 million developers,Git/Mercurial Homepage
  • 63. GITHUB ā€¢ Biggest community exclusively for git ecosystem ā€¢ 316 programming languages, ~6M active users, ~332K activeorganizations, ~19.5M active repositories ā€¢ Main home for any open source project (hosted for free withTravisCI) ā€¢ Most advanced web interface and support for most diffused and evolved development metodologies at any level (Agile,Testing, CI/CD,ā€¦) ā€¢ Highly reliable, but not self-hostable ā€¢ The annual state of the Octoverse
  • 65. GITLAB ā€¢ Fastest development project and community exclusively for git ecosystem: rolling releases and CI ā€¢ More than 100K active organizations self-hosting (2/3 market), ~80% of mobile developers repositories ā€¢ Self-hostable (Vagrant, Docker, native), free public and private repositories with unlimitedmembers ā€¢ Awesome repository management (user permissions,branch protection,Webhooks,ā€¦) ā€¢ Most advanced web interface and support for most diffused and evolved development metodologies at any level (Agile,Testing, CI/CD,ā€¦) ā€¢ Most experimental and cutting-edge solutions for Agile and DevOps metodologies development (Auto DevOps,ā€¦) ā€¢ Full stack of additional features (pages,CI/CD,Cycle,IssueTracker and Board,Review,ā€¦)
  • 66. Demo Git is a state of mind img: Ā©Marvel
  • 67. Extras Git is a state of mind img: Ā©Marvel
  • 68. EXTRA ā€¢ ā€œGitHub cheatsheetā€ - Official basic GitHub cheatsheet ā€¢ ā€œVisual cheatsheetā€ - Interactive cheatsheet ā€¢ ā€œUngitā€ - Interactive web interface ā€¢ ā€œGourceā€ - Repo visualization ā€¢ ā€œGitKrakenā€ - GUI tool ā€¢ ā€œGitHub Desktopā€ - Official GitHub GUI tool
  • 69. References,Resources, License Git is a state of mind img: Ā©Marvel
  • 70. REFERENCES / RESOURCES Conferences ā€œGit From the Bits Upā€ -Tim Berglund ā€œAdvanced GIT for Developersā€ - Lorna Jane Mitchell ā€œGet Started with Gitā€ - DavidBaumgold ā€œAdvanced Gitā€ - DavidBaumgold ā€œA journey intoā€ GIT internals with Python - AndreySyschikov Books Pro Git ā€œGit Best Practices Guideā€ - Eric Pidoux ā€œMastering Gitā€ - Jakub Narębski ā€œLearn enough Git to be dangerousā€ - MichaelHartl
  • 71. LICENSE ā€¢ The whole presentation and the entire content (except where alternatively and explicitly specified) is property of the author, Nicola Costantino, and itā€™s released under the term of the ā€œCreative CommonsAttribution - NonCommercial - NoDerivatives 4.0 International Licenseā€ ā€¢ All third party media contents are property of their respective owners and are hereby only used for teaching purposes
  • 72. You better learn itā€¦ Source:Youtube
  • 73. ThankYou! Git is a state of mind img: Ā©Marvel
  • 74. Nicola Costantino ā€¢ nicolacostantino.com ā€¢ Twitter: https://twitter.com/theroadtodark ā€¢ Medium: https://medium.com/ @theroadtodarkness ā€¢ GitHub: https://github.com/NicolaCostantino ā€¢ Linkedin: https://www.linkedin.com/in/ nicolacostantino/ About (Work In Progress) meā€¦