SlideShare a Scribd company logo
1 of 42
Download to read offline
Don't be a git
The essentials you should know
about git to use correctly
Otto Kekäläinen
Vincit Teatime 11.11.2015
Tampere,Finland
@ottokekalainen
●
15+ years in open source
●
technology & business & advocacy
●
development with git since 2010
Git / t/ɡɪ
”A silly,incompetent,stupid,
annoying or childish person.”
http://en.wiktionary.org/wiki/git
"I'm an egotistical bastard,so I
name all my projects after myself.
First Linux,now Git”
Linus Torvalds,PC World.2012-07-14
Linus needed a new source code revision manager for
Linux,and none of the available options in 2005 where
good enough,so he wrote his own in.
Kernel 2.6.12 was the first release managed by Git and
version 1.0 of Git was released in December 2005.
Git popularity according to OpenHub.net
Git popularity according to Google Trends
git
svn
...but adoption would be faster if it was
not so difficult to use.
Originally Linus did not intend end users to use Git
directly,instead he tried to delegate to somebody
else the task of making the actual command line
interface. We are still waiting for it...
Luckily Git has been simplified and documentation
has improved over time,but some Git commands
still refer to Git internals that are difficult to grasp.
E.g. git-push: Update remote refs along with
associated objects.
Git might feel difficult at first,
but once you learn it, you never
want to go back to anything less
flexible and powerful.
First obstacle: same terms with different meanings
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
Define the author of commits
git pull
# edit files
git commit -am “Implemented X”
git push
git log
git show
https://help.github.com/articles/generating-ssh-keys/
Learn the basics: http://try.github.com/
How to write a good commit message
●
Your attitude towards commit messages should be the same as for code:
it is written once,but read thousands of times.
●
Don't explain how was done,that is visible in the diff anyway.Explain
what the intention was and why it was made.
●
Use imperative form “Fix typo”(instead of “Fixed typo”)
●
Keep subject line short and sweet,under 72 chars.Body can be verbose.
●
Use proper English.Capital letters.Reference issue identifiers is
possible.
●
Looking for a good example? How about one by Linus himself?
https://github.com/torvalds/linux/commit/fc90888
Use git commit -a --amend to you screwed up
the commit and want to overwrite the latest
with an improved commit.
Completely delete the last commit:
git reset --hard HEAD^
Delete all untracked and modified files:
git clean -fdx && git reset --hard
Use branches and tags
Basically just labels that point to certain commit IDs.
Each commit ID point to its parent,thus forms a chain.
All developers branch from
master and then merge back.
New releases branch
from master.
Support releases branch
from release branch.
Image source:
http://tleyden.github.io/blog/
2014/04/09/a-successful-git-br
anching-model-with-enterprise-
support/
Git layout strategy 1/2
●
Start working on the master branch only.Don't create other
branches until you really need them.
●
Every new developer has their own branch (local clone).
●
Never break master. Push only stuff what works.Other
developers must be able to branch from master at any time
and start working on something new,instead of having to deal
with fixing a broken state that somebody else left in master.
Git layout strategy 2/2
●
If you have a need to push your work that is half-way done,that is a
good signal that you should create a new branch.
●
Typically tree kind of branches:
– feature branches
– bugfix branches
– personal branches
●
Project layout: split code up in many separate files.
– Lower likelihood of conflicting changes when branches merge.
Distributed version control?
Example scenarios at
https://git-scm.com/about/distributed
Compare changes and create diffs
git show 166a2f284875
# standard show in patch format
git diff v1.2.3..HEAD translations/ > new-translations.diff
# diff of all changes in directory translation/ since tag v.1.2.3
git diff branch1 branch2 # compare two branches
git diff branch1..branch2 # same as above
git diff branch1...branch2 # tree dots: changes on branch2 since it diverged
GUI tool: gitk
●
graphical tool to view git history (and also uncommitted changes)
●
shows all commits,tags,branch names etc in a nice way
●
with gitk you don’t need to checkout the branch/file to view it
●
includes search feature for both commit messages and commit contents
●
run “gitk example/file.h”to see the git log that affects a single file
●
“git gui blame”can be used to view graphically via the context menu that opens when
clicking on a commit with the secondary mouse button
●
view diff between any two diffs: click on first commit normally,and then click with
secondary button on the second commit and select from context menu to view the diff
●
run “gitk mariadb-10.1.4..mariadb-10.1.5”to view diff between two commits
●
you can also view diff between different branches like this
– gitk 10.1..HEAD vs gitk HEAD..10.1 vs gitk 10.1...HEAD
Other GUI tools
●
git citool –graphical tool to do selective commits easily
– you can click to select the files you want,individual hunks inside
files,and even individual lines inside hunks
– you can also write commits inside the tool’s window
●
git mergetool –tool for easy merging,
– automatically launches the pre-configured 3-way merge tool for
all conflicts (e.g.meld)
Keep branch name visible in the bash prompt:
https://github.com/ottok/tooling/blob/master/bashrc/bashrc.git
Git internals
Folder /.git contains everything,
your / is just the working copy.
Folder /.git contains everything,
your / is just the working copy.
When you commit a 2 MB file /example.png,
your / will grow to 4 MB...
When you add a file,
it goes to the staging area.
The file does not go into the
actual history tree until the stage
is committed.
Git tracks content,not files!
Git history is immutable as each commit ID is the SHA-1 of
the commit data and metadata (including the commit ID of
parents).Changing any commit in the history will change the
SHA-1 commit IDs of every following commit in the chain.
If you need to change something in the history,you have to
rebase and make a new history.
Git commit IDs and rebase
Original git log --oneline
1bf7024 MDEV-8991: bind-address appears twice in default my.cnf
b2205c5 MDEV-9011: Redo log encryption does not work
cf9e6b2 Fix test failures seen on buildbot.
923827e MDEV-7949: Item_field::used_tables() takes 0.29% in OLTP RO
239e0c5 MDEV-8551 compilation fails with 10.1.6
After git rebase -i HEAD^^^
34350b9 MDEV-8991: bind-address appears twice in default my.cnf
f5f2dd9 MDEV-9011: Redo log encryption does not work
531e1ac Fixed all bugs
923827e MDEV-7949: Item_field::used_tables() takes 0.29% in OLTP RO
239e0c5 MDEV-8551 compilation fails with 10.1.6
Example of how fast-forward works 1/2
●
Branch“feature-branch-example”forked from master branch
“10.1”and has 3 commits
Example of how fast-forward works 2/2
●
Normal merge defaults to fast-forward in this case
●
●
●
Result of no fast-forward (git merge --no-ff)
Want to avoid “ugly”merge commits?
●
git config pull.ff=only
●
git config alias.ff=merge --ff-only
●
Run git rebase master to rebase you work on the master branch
before pushing or making pull request
– In MariaDB before submitting a pull request: git rebase 10.1
– You changes will be based on current 10.1 head and easy to merge
●
Run git merge on when importing changes from remote head only if
you really want to merge
Cherry-pick as alternative to merge
git cherry-pick 166a2f28487530ead0cf813ce0252baa
The commit with given ID will be applied as a new commit on
top of your current branch head (only commit ID updates).
Git bisect –find the commit that broke you app
git bisect bad # mark the checked out commit as bad
git bisect good mariadb-10.1.7 # mark the ref (=commit) good
git bisect run my-test.sh
Git automatically checks out every commit between “bad”and “good”and runs
the test script.
Test script is supposed to return 0 for good commits and non-0 for bad commits.
Exceptions are exit codes 255 and 125 that have special meaning to git bisect.
When the run is completed git will tell you the exact commit between “good”and
“bad”where the my-test.sh started to fail (exit code not 0).
Git hooks and CI
Git commit hook: stop bad code entering repo
/.git/hooks$ cat pre-commit
#!/bin/bash
# Really fast check if syntax is at all parseable
for FILE in $(git diff --cached --name-only); do
if [[ "$FILE" =~ .php$ ]]; then
php -l "$FILE" 1> /dev/null
if [[ $? -ne 0 ]]; then
echo -e "e[1;33mAborting commit: PHP code contains syntax errorse[0m" >&2
exit 1
fi
fi
done
Want to put a simple shared repository on any SSH
capable server? Create a bare .git with no working files:
git init --bare
Want to have notifications when somebody commits?
Put a shell script at .git/hooks/post-receive
Continuous integration
●
Host your own Jenkins?
●
Travis-CI
Will Github (or Gitlab) profile pages
replace developers CV's?
Something to think about
Contact Seravo if you need experts in
Linux,Git,Docker,WordPress or other
open source software
Open seravo.fi
See our blog for in-depth tips

More Related Content

What's hot

An Introduction to Git (even for non-developers)
An Introduction to Git (even for non-developers)An Introduction to Git (even for non-developers)
An Introduction to Git (even for non-developers)John Anderson
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
01 git interview questions & answers
01   git interview questions & answers01   git interview questions & answers
01 git interview questions & answersDeepQuest Software
 
Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and githubAderemi Dadepo
 
Understanding pseudo-version and Go1.14+ with notes
Understanding pseudo-version and Go1.14+ with notesUnderstanding pseudo-version and Go1.14+ with notes
Understanding pseudo-version and Go1.14+ with notesMitali Bisht
 
Inside GitHub
Inside GitHubInside GitHub
Inside GitHuberr
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-realEneldo Serrata
 
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 and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperJohn Stevenson
 

What's hot (20)

Git Basics
Git BasicsGit Basics
Git Basics
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Git advanced
Git advancedGit advanced
Git advanced
 
An Introduction to Git (even for non-developers)
An Introduction to Git (even for non-developers)An Introduction to Git (even for non-developers)
An Introduction to Git (even for non-developers)
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
01 git interview questions & answers
01   git interview questions & answers01   git interview questions & answers
01 git interview questions & answers
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Git
GitGit
Git
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Did you git yet?
Did you git yet?Did you git yet?
Did you git yet?
 
Git and git hub
Git and git hubGit and git hub
Git and git hub
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and github
 
Understanding pseudo-version and Go1.14+ with notes
Understanding pseudo-version and Go1.14+ with notesUnderstanding pseudo-version and Go1.14+ with notes
Understanding pseudo-version and Go1.14+ with notes
 
Inside GitHub
Inside GitHubInside GitHub
Inside GitHub
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-real
 
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...
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
 

Viewers also liked

MariaDB in Debian and Ubuntu: The next million users
MariaDB in Debian and Ubuntu: The next million usersMariaDB in Debian and Ubuntu: The next million users
MariaDB in Debian and Ubuntu: The next million usersOtto Kekäläinen
 
Collaboration in open source - examples from MariaDB
Collaboration in open source - examples from MariaDBCollaboration in open source - examples from MariaDB
Collaboration in open source - examples from MariaDBOtto Kekäläinen
 
MariaDB Developers Meetup 2016 welcome words
MariaDB Developers Meetup 2016 welcome wordsMariaDB Developers Meetup 2016 welcome words
MariaDB Developers Meetup 2016 welcome wordsOtto Kekäläinen
 
WordPress ja markkinointiautomaatio (DigitalTre-esitys)
WordPress ja markkinointiautomaatio (DigitalTre-esitys)WordPress ja markkinointiautomaatio (DigitalTre-esitys)
WordPress ja markkinointiautomaatio (DigitalTre-esitys)Otto Kekäläinen
 
Koodikerho: ohjelmointia alakouluissa
Koodikerho: ohjelmointia alakouluissaKoodikerho: ohjelmointia alakouluissa
Koodikerho: ohjelmointia alakouluissaOtto Kekäläinen
 
Koodikerho PEPE Pajapäivä 6.9.2016
Koodikerho PEPE Pajapäivä 6.9.2016Koodikerho PEPE Pajapäivä 6.9.2016
Koodikerho PEPE Pajapäivä 6.9.2016Otto Kekäläinen
 
WordPress security 101 - WP Turku Meetup 2.2.2017
WordPress security 101 - WP Turku Meetup 2.2.2017WordPress security 101 - WP Turku Meetup 2.2.2017
WordPress security 101 - WP Turku Meetup 2.2.2017Otto Kekäläinen
 
MariaDB Foundation presentation and membership info
MariaDB Foundation presentation and membership infoMariaDB Foundation presentation and membership info
MariaDB Foundation presentation and membership infoOtto Kekäläinen
 
WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...
WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...
WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...Otto Kekäläinen
 
Find WordPress performance bottlenecks with XDebug PHP profiling
Find WordPress performance bottlenecks with XDebug PHP profilingFind WordPress performance bottlenecks with XDebug PHP profiling
Find WordPress performance bottlenecks with XDebug PHP profilingOtto Kekäläinen
 
Testing and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressionsTesting and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressionsOtto Kekäläinen
 
Less passwords, more security: unix socket authentication and other MariaDB h...
Less passwords, more security: unix socket authentication and other MariaDB h...Less passwords, more security: unix socket authentication and other MariaDB h...
Less passwords, more security: unix socket authentication and other MariaDB h...Otto Kekäläinen
 
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017Otto Kekäläinen
 
Koodikerho opettaa lapsille ohjelmointia (Virtuaaliopetuksen päivät 2015)
Koodikerho opettaa lapsille ohjelmointia (Virtuaaliopetuksen päivät 2015)Koodikerho opettaa lapsille ohjelmointia (Virtuaaliopetuksen päivät 2015)
Koodikerho opettaa lapsille ohjelmointia (Virtuaaliopetuksen päivät 2015)Otto Kekäläinen
 

Viewers also liked (15)

MariaDB in Debian and Ubuntu: The next million users
MariaDB in Debian and Ubuntu: The next million usersMariaDB in Debian and Ubuntu: The next million users
MariaDB in Debian and Ubuntu: The next million users
 
Collaboration in open source - examples from MariaDB
Collaboration in open source - examples from MariaDBCollaboration in open source - examples from MariaDB
Collaboration in open source - examples from MariaDB
 
MariaDB Developers Meetup 2016 welcome words
MariaDB Developers Meetup 2016 welcome wordsMariaDB Developers Meetup 2016 welcome words
MariaDB Developers Meetup 2016 welcome words
 
WordPress ja markkinointiautomaatio (DigitalTre-esitys)
WordPress ja markkinointiautomaatio (DigitalTre-esitys)WordPress ja markkinointiautomaatio (DigitalTre-esitys)
WordPress ja markkinointiautomaatio (DigitalTre-esitys)
 
Koodikerho: ohjelmointia alakouluissa
Koodikerho: ohjelmointia alakouluissaKoodikerho: ohjelmointia alakouluissa
Koodikerho: ohjelmointia alakouluissa
 
Koodikerho PEPE Pajapäivä 6.9.2016
Koodikerho PEPE Pajapäivä 6.9.2016Koodikerho PEPE Pajapäivä 6.9.2016
Koodikerho PEPE Pajapäivä 6.9.2016
 
WordPress security 101 - WP Turku Meetup 2.2.2017
WordPress security 101 - WP Turku Meetup 2.2.2017WordPress security 101 - WP Turku Meetup 2.2.2017
WordPress security 101 - WP Turku Meetup 2.2.2017
 
MariaDB Foundation presentation and membership info
MariaDB Foundation presentation and membership infoMariaDB Foundation presentation and membership info
MariaDB Foundation presentation and membership info
 
WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...
WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...
WordPress Security 101 – WordCamp Finland 2016 presentation by Otto Kekäläine...
 
Find WordPress performance bottlenecks with XDebug PHP profiling
Find WordPress performance bottlenecks with XDebug PHP profilingFind WordPress performance bottlenecks with XDebug PHP profiling
Find WordPress performance bottlenecks with XDebug PHP profiling
 
Testing and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressionsTesting and updating WordPress - Advanced techniques for avoiding regressions
Testing and updating WordPress - Advanced techniques for avoiding regressions
 
Less passwords, more security: unix socket authentication and other MariaDB h...
Less passwords, more security: unix socket authentication and other MariaDB h...Less passwords, more security: unix socket authentication and other MariaDB h...
Less passwords, more security: unix socket authentication and other MariaDB h...
 
Git best practices 2016
Git best practices 2016Git best practices 2016
Git best practices 2016
 
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
WordPress security 101 - WP Jyväskylä Meetup 21.3.2017
 
Koodikerho opettaa lapsille ohjelmointia (Virtuaaliopetuksen päivät 2015)
Koodikerho opettaa lapsille ohjelmointia (Virtuaaliopetuksen päivät 2015)Koodikerho opettaa lapsille ohjelmointia (Virtuaaliopetuksen päivät 2015)
Koodikerho opettaa lapsille ohjelmointia (Virtuaaliopetuksen päivät 2015)
 

Similar to Git essentials

Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?9 series
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - WorkflowTahsin Abrar
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow Sebin Benjamin
 
Git basics a starter on git and its ecosystem
Git basics  a starter on git and its ecosystemGit basics  a starter on git and its ecosystem
Git basics a starter on git and its ecosystemFrançois D'Agostini
 
Git tech talk
Git tech talkGit tech talk
Git tech talkrazasayed
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenchesNuno Caneco
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdfAliaaTarek5
 
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
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfmurad khan
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshellalignan
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptxHitesh670643
 

Similar to Git essentials (20)

Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Git basics a starter on git and its ecosystem
Git basics  a starter on git and its ecosystemGit basics  a starter on git and its ecosystem
Git basics a starter on git and its ecosystem
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenches
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 
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
 
Git Primer
Git PrimerGit Primer
Git Primer
 
Use Git like a pro - condensed
Use Git like a pro - condensedUse Git like a pro - condensed
Use Git like a pro - condensed
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 
3 Git
3 Git3 Git
3 Git
 
Git training with Devaamo
Git training with DevaamoGit training with Devaamo
Git training with Devaamo
 
Git introduction
Git introductionGit introduction
Git introduction
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
Git github
Git githubGit github
Git github
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
 

More from Otto Kekäläinen

FOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
FOSDEM2021: MariaDB post-release quality assurance in Debian and UbuntuFOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
FOSDEM2021: MariaDB post-release quality assurance in Debian and UbuntuOtto Kekäläinen
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itOtto Kekäläinen
 
MariaDB quality assurance in Debian and Ubuntu
MariaDB quality assurance in Debian and UbuntuMariaDB quality assurance in Debian and Ubuntu
MariaDB quality assurance in Debian and UbuntuOtto Kekäläinen
 
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?Otto Kekäläinen
 
Technical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 editionTechnical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 editionOtto Kekäläinen
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...Otto Kekäläinen
 
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...Otto Kekäläinen
 
DebConf 2019 MariaDB packaging in Debian BoF
DebConf 2019 MariaDB packaging in Debian BoFDebConf 2019 MariaDB packaging in Debian BoF
DebConf 2019 MariaDB packaging in Debian BoFOtto Kekäläinen
 
The 5 most common reasons for a slow WordPress site and how to fix them
The 5 most common reasons for a slow WordPress site and how to fix themThe 5 most common reasons for a slow WordPress site and how to fix them
The 5 most common reasons for a slow WordPress site and how to fix themOtto Kekäläinen
 
How to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressHow to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressOtto Kekäläinen
 
Automatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesAutomatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesOtto Kekäläinen
 
10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...Otto Kekäläinen
 
Automatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress pluginsAutomatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress pluginsOtto Kekäläinen
 
Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)Otto Kekäläinen
 
WordPress-tietoturvan perusteet
WordPress-tietoturvan perusteetWordPress-tietoturvan perusteet
WordPress-tietoturvan perusteetOtto Kekäläinen
 
Technical SEO for WordPress - 2017 edition
Technical SEO for WordPress - 2017 editionTechnical SEO for WordPress - 2017 edition
Technical SEO for WordPress - 2017 editionOtto Kekäläinen
 
Improving WordPress Performance with Xdebug and PHP Profiling
Improving WordPress Performance with Xdebug and PHP ProfilingImproving WordPress Performance with Xdebug and PHP Profiling
Improving WordPress Performance with Xdebug and PHP ProfilingOtto Kekäläinen
 
MariaDB adoption in Linux distributions and development environments
MariaDB adoption in Linux distributions and development environmentsMariaDB adoption in Linux distributions and development environments
MariaDB adoption in Linux distributions and development environmentsOtto Kekäläinen
 
DebConf16 BoF on MariaDB/MySQL packaging
DebConf16 BoF on MariaDB/MySQL packagingDebConf16 BoF on MariaDB/MySQL packaging
DebConf16 BoF on MariaDB/MySQL packagingOtto Kekäläinen
 

More from Otto Kekäläinen (20)

FOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
FOSDEM2021: MariaDB post-release quality assurance in Debian and UbuntuFOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
FOSDEM2021: MariaDB post-release quality assurance in Debian and Ubuntu
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize it
 
MariaDB quality assurance in Debian and Ubuntu
MariaDB quality assurance in Debian and UbuntuMariaDB quality assurance in Debian and Ubuntu
MariaDB quality assurance in Debian and Ubuntu
 
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
DebConf 2020: What’s New in MariaDB Server 10.5 and Galera 4?
 
Technical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 editionTechnical SEO for WordPress - 2019 edition
Technical SEO for WordPress - 2019 edition
 
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...The 5 most common reasons for a slow WordPress site and how to fix them – ext...
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
 
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
How MariaDB packaging uses Salsa-CI to ensure smooth upgrades and avoid regre...
 
DebConf 2019 MariaDB packaging in Debian BoF
DebConf 2019 MariaDB packaging in Debian BoFDebConf 2019 MariaDB packaging in Debian BoF
DebConf 2019 MariaDB packaging in Debian BoF
 
The 5 most common reasons for a slow WordPress site and how to fix them
The 5 most common reasons for a slow WordPress site and how to fix themThe 5 most common reasons for a slow WordPress site and how to fix them
The 5 most common reasons for a slow WordPress site and how to fix them
 
How to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPressHow to investigate and recover from a security breach in WordPress
How to investigate and recover from a security breach in WordPress
 
Technical SEO for WordPress
Technical SEO for WordPressTechnical SEO for WordPress
Technical SEO for WordPress
 
Automatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesAutomatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themes
 
10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...
 
Automatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress pluginsAutomatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress plugins
 
Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)
 
WordPress-tietoturvan perusteet
WordPress-tietoturvan perusteetWordPress-tietoturvan perusteet
WordPress-tietoturvan perusteet
 
Technical SEO for WordPress - 2017 edition
Technical SEO for WordPress - 2017 editionTechnical SEO for WordPress - 2017 edition
Technical SEO for WordPress - 2017 edition
 
Improving WordPress Performance with Xdebug and PHP Profiling
Improving WordPress Performance with Xdebug and PHP ProfilingImproving WordPress Performance with Xdebug and PHP Profiling
Improving WordPress Performance with Xdebug and PHP Profiling
 
MariaDB adoption in Linux distributions and development environments
MariaDB adoption in Linux distributions and development environmentsMariaDB adoption in Linux distributions and development environments
MariaDB adoption in Linux distributions and development environments
 
DebConf16 BoF on MariaDB/MySQL packaging
DebConf16 BoF on MariaDB/MySQL packagingDebConf16 BoF on MariaDB/MySQL packaging
DebConf16 BoF on MariaDB/MySQL packaging
 

Recently uploaded

WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 

Recently uploaded (20)

WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

Git essentials

  • 1. Don't be a git The essentials you should know about git to use correctly Otto Kekäläinen Vincit Teatime 11.11.2015 Tampere,Finland
  • 2. @ottokekalainen ● 15+ years in open source ● technology & business & advocacy ● development with git since 2010
  • 3. Git / t/ɡɪ ”A silly,incompetent,stupid, annoying or childish person.” http://en.wiktionary.org/wiki/git
  • 4. "I'm an egotistical bastard,so I name all my projects after myself. First Linux,now Git” Linus Torvalds,PC World.2012-07-14
  • 5. Linus needed a new source code revision manager for Linux,and none of the available options in 2005 where good enough,so he wrote his own in. Kernel 2.6.12 was the first release managed by Git and version 1.0 of Git was released in December 2005.
  • 6. Git popularity according to OpenHub.net
  • 7. Git popularity according to Google Trends git svn
  • 8. ...but adoption would be faster if it was not so difficult to use. Originally Linus did not intend end users to use Git directly,instead he tried to delegate to somebody else the task of making the actual command line interface. We are still waiting for it... Luckily Git has been simplified and documentation has improved over time,but some Git commands still refer to Git internals that are difficult to grasp. E.g. git-push: Update remote refs along with associated objects.
  • 9. Git might feel difficult at first, but once you learn it, you never want to go back to anything less flexible and powerful.
  • 10. First obstacle: same terms with different meanings
  • 11. git config --global user.name "John Doe" git config --global user.email johndoe@example.com Define the author of commits
  • 12. git pull # edit files git commit -am “Implemented X” git push git log git show https://help.github.com/articles/generating-ssh-keys/ Learn the basics: http://try.github.com/
  • 13. How to write a good commit message ● Your attitude towards commit messages should be the same as for code: it is written once,but read thousands of times. ● Don't explain how was done,that is visible in the diff anyway.Explain what the intention was and why it was made. ● Use imperative form “Fix typo”(instead of “Fixed typo”) ● Keep subject line short and sweet,under 72 chars.Body can be verbose. ● Use proper English.Capital letters.Reference issue identifiers is possible. ● Looking for a good example? How about one by Linus himself? https://github.com/torvalds/linux/commit/fc90888
  • 14.
  • 15. Use git commit -a --amend to you screwed up the commit and want to overwrite the latest with an improved commit. Completely delete the last commit: git reset --hard HEAD^ Delete all untracked and modified files: git clean -fdx && git reset --hard
  • 17. Basically just labels that point to certain commit IDs. Each commit ID point to its parent,thus forms a chain.
  • 18. All developers branch from master and then merge back. New releases branch from master. Support releases branch from release branch. Image source: http://tleyden.github.io/blog/ 2014/04/09/a-successful-git-br anching-model-with-enterprise- support/
  • 19. Git layout strategy 1/2 ● Start working on the master branch only.Don't create other branches until you really need them. ● Every new developer has their own branch (local clone). ● Never break master. Push only stuff what works.Other developers must be able to branch from master at any time and start working on something new,instead of having to deal with fixing a broken state that somebody else left in master.
  • 20. Git layout strategy 2/2 ● If you have a need to push your work that is half-way done,that is a good signal that you should create a new branch. ● Typically tree kind of branches: – feature branches – bugfix branches – personal branches ● Project layout: split code up in many separate files. – Lower likelihood of conflicting changes when branches merge.
  • 21. Distributed version control? Example scenarios at https://git-scm.com/about/distributed
  • 22. Compare changes and create diffs git show 166a2f284875 # standard show in patch format git diff v1.2.3..HEAD translations/ > new-translations.diff # diff of all changes in directory translation/ since tag v.1.2.3 git diff branch1 branch2 # compare two branches git diff branch1..branch2 # same as above git diff branch1...branch2 # tree dots: changes on branch2 since it diverged
  • 23. GUI tool: gitk ● graphical tool to view git history (and also uncommitted changes) ● shows all commits,tags,branch names etc in a nice way ● with gitk you don’t need to checkout the branch/file to view it ● includes search feature for both commit messages and commit contents ● run “gitk example/file.h”to see the git log that affects a single file ● “git gui blame”can be used to view graphically via the context menu that opens when clicking on a commit with the secondary mouse button ● view diff between any two diffs: click on first commit normally,and then click with secondary button on the second commit and select from context menu to view the diff ● run “gitk mariadb-10.1.4..mariadb-10.1.5”to view diff between two commits ● you can also view diff between different branches like this – gitk 10.1..HEAD vs gitk HEAD..10.1 vs gitk 10.1...HEAD
  • 24. Other GUI tools ● git citool –graphical tool to do selective commits easily – you can click to select the files you want,individual hunks inside files,and even individual lines inside hunks – you can also write commits inside the tool’s window ● git mergetool –tool for easy merging, – automatically launches the pre-configured 3-way merge tool for all conflicts (e.g.meld)
  • 25. Keep branch name visible in the bash prompt: https://github.com/ottok/tooling/blob/master/bashrc/bashrc.git
  • 27. Folder /.git contains everything, your / is just the working copy.
  • 28. Folder /.git contains everything, your / is just the working copy. When you commit a 2 MB file /example.png, your / will grow to 4 MB...
  • 29. When you add a file, it goes to the staging area. The file does not go into the actual history tree until the stage is committed.
  • 30. Git tracks content,not files! Git history is immutable as each commit ID is the SHA-1 of the commit data and metadata (including the commit ID of parents).Changing any commit in the history will change the SHA-1 commit IDs of every following commit in the chain. If you need to change something in the history,you have to rebase and make a new history.
  • 31. Git commit IDs and rebase Original git log --oneline 1bf7024 MDEV-8991: bind-address appears twice in default my.cnf b2205c5 MDEV-9011: Redo log encryption does not work cf9e6b2 Fix test failures seen on buildbot. 923827e MDEV-7949: Item_field::used_tables() takes 0.29% in OLTP RO 239e0c5 MDEV-8551 compilation fails with 10.1.6 After git rebase -i HEAD^^^ 34350b9 MDEV-8991: bind-address appears twice in default my.cnf f5f2dd9 MDEV-9011: Redo log encryption does not work 531e1ac Fixed all bugs 923827e MDEV-7949: Item_field::used_tables() takes 0.29% in OLTP RO 239e0c5 MDEV-8551 compilation fails with 10.1.6
  • 32. Example of how fast-forward works 1/2 ● Branch“feature-branch-example”forked from master branch “10.1”and has 3 commits
  • 33. Example of how fast-forward works 2/2 ● Normal merge defaults to fast-forward in this case ● ● ● Result of no fast-forward (git merge --no-ff)
  • 34. Want to avoid “ugly”merge commits? ● git config pull.ff=only ● git config alias.ff=merge --ff-only ● Run git rebase master to rebase you work on the master branch before pushing or making pull request – In MariaDB before submitting a pull request: git rebase 10.1 – You changes will be based on current 10.1 head and easy to merge ● Run git merge on when importing changes from remote head only if you really want to merge
  • 35. Cherry-pick as alternative to merge git cherry-pick 166a2f28487530ead0cf813ce0252baa The commit with given ID will be applied as a new commit on top of your current branch head (only commit ID updates).
  • 36. Git bisect –find the commit that broke you app git bisect bad # mark the checked out commit as bad git bisect good mariadb-10.1.7 # mark the ref (=commit) good git bisect run my-test.sh Git automatically checks out every commit between “bad”and “good”and runs the test script. Test script is supposed to return 0 for good commits and non-0 for bad commits. Exceptions are exit codes 255 and 125 that have special meaning to git bisect. When the run is completed git will tell you the exact commit between “good”and “bad”where the my-test.sh started to fail (exit code not 0).
  • 38. Git commit hook: stop bad code entering repo /.git/hooks$ cat pre-commit #!/bin/bash # Really fast check if syntax is at all parseable for FILE in $(git diff --cached --name-only); do if [[ "$FILE" =~ .php$ ]]; then php -l "$FILE" 1> /dev/null if [[ $? -ne 0 ]]; then echo -e "e[1;33mAborting commit: PHP code contains syntax errorse[0m" >&2 exit 1 fi fi done
  • 39. Want to put a simple shared repository on any SSH capable server? Create a bare .git with no working files: git init --bare Want to have notifications when somebody commits? Put a shell script at .git/hooks/post-receive
  • 40. Continuous integration ● Host your own Jenkins? ● Travis-CI
  • 41. Will Github (or Gitlab) profile pages replace developers CV's? Something to think about
  • 42. Contact Seravo if you need experts in Linux,Git,Docker,WordPress or other open source software Open seravo.fi See our blog for in-depth tips