SlideShare a Scribd company logo
Practical git for developers
(aka 'Git for beginners')
Wim Godden
Cu.be Solutions
@wimgtr
Who am I ?
Wim Godden (@wimgtr)
Where I'm from
Where I'm from
Where I'm from
Where I'm from
Where I'm from
Where I'm from
My town
My town
Belgium – the traffic
Who am I ?
Wim Godden (@wimgtr)
Founder of Cu.be Solutions (http://cu.be)
Open Source developer since 1997
Developer of PHPCompatibility, OpenX, PHPConsistent, ...
Speaker at Open Source conferences
Who are you ?
Developers ?
CVS ?
SVN ?
TFS ?
Git ?
What is git ?
Git is a file system
with a Version Control System on top of it
Git's file structure
Commit
tree
author_info
parent
Tree
README.MD
LICENSE
index.php
Blob
datadatadata...
Blob
datadatadata...
Blob
datadatadata...
6d3af... 8a3ea...
901a3...
4a39c...
e3231...
8a3ea... 901a3...
4a39c...
e3231...
What is git ?
Git is a file system
with a Version Control System on top of it
What is git ?
Git is a distributed file system
with a Version Control System on top of it
(Almost) everything is local
Clone = copy of entire repository
Work offline :
Perform a diff
View file history
Commit changes (!)
Create, merge or switch branches
etc.
Only push/pull are not local
(Almost) everything is immutable
Immutable = doesn't change
Once placed in git, it stays there
Even if you delete files
Differences with SVN
SVN keeps diffs between versions
Git keeps full snapshots
Commit #1
tree
author_info
parent
Tree
README.MD
Commit #2
tree
author_info
parent
Tree
README.MD
index.php
Commit #3
tree
author_info
parent
Tree
README.MD
LICENSE
index.php
Differences with SVN
SVN is centralized
↔ Git is distributed
An SVN commit → shared with everyone
↔ A Git commit is local
SVN has revision increments
↔ Git has SHA1 hashes to identify objects
(commits, trees, blobs, ...)
Basic git – config
$ git config --global user.name "Wim Godden"
$ git config --global user.email "wim.godden@cu.be"
$ git config --global core.editor vim
$ git config --global core.autocrlf input
$ git config --global core.autocrlf true
$ git config --global color.ui true
(on Linux)
(on Windows)
Basic git - .gitignore
Allows you to specify files to ignore
Can be specific to repository
Hint : set up a global .gitignore for :
thumbnail.dat
desktop.ini
.DS_Store
Your local editor's files
…
Create a repo
$ git init
$ tree .git
.git/
├── branches
├── config
├── description
├── HEAD
├── info
│   └── exclude
├── objects
│   ├── info
│   └── pack
└── refs
├── heads
└── tags
.git directory
config – Configuration file
refs/heads/... - branches
refs/tags/... - tags
refs/remotes/... - remotes
objects/... - the actual objects
HEAD – the current working space, points to one of branches
git clone
Creates a repository from an existing repository
git clone https://someplace.com/repo.git <somefolder>
Original repository is called 'origin'
→ This is called a 'remote'
Git flow
Working directory
Staging area
Repository
Remote(s)
Add
Commit
Push
git status
Simple command
Explains in clear language what's going on
Use it, use it, use it, ...
Git flow
Working directory
Staging area
Repository
Remote(s)
Add
Commit
Push
git add
Add file in current state to the staging area
Can be new file
Can be modification
git add -A stages all
git add . stages new and modified, but no deletions
git add -u stages modified and deleted, but no new files
git reset
Unstage changes
Revert to older commit version
Beware : dangerous command !
Remove files from repository
2 ways :
Delete, then rm
Delete the file from working directory
git rm <filename>
Commit
Just rm
git rm <filename>
Commit
Accidentially deleted ?
→ git checkout -- <filename>
Git flow
Working directory
Staging area
Repository
Remote(s)
Add
Commit
Push
git commit
Creates a new version
Based on the staging area
Commits on local repository only
Commit #1
tree
author_info
parent
Tree
README.MD
Commit #2
tree
author_info
parent : #1
Tree
README.MD
index.php
Commit #3
tree
author_info
parent : #2
Tree
README.MD
LICENSE
index.php
HEAD
git log
Shows each commit with SHA1 hash
→ hash can be used with other commands
-p gives a diff view
git diff
No params : default diff output
git diff --staged : diff with what's been staged
Clone, add, commit and push
C1
Remote originLocal repository
C2
master
C1 C2
origin/master
1 2
C1 C2
origin/master
C3
master HEAD
master HEAD1
2 C1 C2
master
C1 C2
origin/master
C3
master HEAD
3
3
C1 C2
master
C3
Working with remotes
git push
→ Send locally commited changes to the remote repository
git fetch/pull
→ Retrieve changes from the remote repository
Fetch, merge and pull
Remote originLocal repository
C1 C2
origin/master
1 2
C1 C2
origin/master
C3
master HEAD
master HEAD
1
C1 C2 C3
master HEAD
2
3
C1 C2
master
C3C2
origin/master 3
git fetch + merge vs git pull
git fetch : fetches information from remote into local repository
but nothing more
git merge : merges changes that were fetched
needs a source parameter
merges TO wherever HEAD is pointing to :
git merge origin/master
git pull : does both at the same time
Branches
Branches are separate full-blown versions of your code
Default branch = master
Which branches are there ? → git branch
Create a new branch → git branch <branchname>
Switch to branch → git checkout <branchname>
Create + switch to new branch → git checkout -b <branchname>
Show branch activity : git show-branch
Delete a branch : git branch -d <branchname>
Merging changes in a project
C1 C2
origin/master
C1 C2
origin/master
C3
master
master
C4 test
LICENSE : added paragraph 1
LICENSE : added paragraph 2
C1 C2
origin/master
C3 master
C4 test
LICENSE : added paragraph 1 + 2
Edited LICENSE
C5
Conflicting change
git merge <branchname> → conflict
git status → shows conflicted files
Resolve conflict
git commit -a → tells git conflict was resolved
Contributing to a Github project
Github is built on Git, so...
Clone, commit, pull, merge, push are all the same
But :
You need to fork the project first
Changes to the main repository must be requested through a
pull request
Creating a fork
Creating a fork
Will create a complete copy (not a clone) of the project
Including master, all branches, all tags, all commits, etc.
i.e. confoo/some-repo → <your_github_username>/some-repo
You can do anything in it...
But please don't if you intend to contribute back...
Which you should ofcourse ;-)
Next : create a branch for your feature/bugfix
Why ?
Work on multiple features/fixes at same time
Experiment without damaging your master
master should always be a fully functioning, deployable version
Name the branch well
Don't : bugfix
Do : bugfix_issue_26_fatal_error
Next : add/change code and commit
Don't forget unit tests, integration tests, …
Make your commit message descriptive
Don't : fixed it
Do : added real-time updates on dashboard
Each commit should contain a single feature or bugfix
→ Allows project maintainers to add small blocks of code
→ Easier than adding 50 features/bugfixes
→ Easier to test
Next : create a Pull Request (PR)
When you want to contribute
Partial code = OK
→ But only if you want feedback
Otherwise :
Finish your code
Make sure you have unit tests
Be descriptive in your pull request
Don't : “this will fix my issues”
Do : “Added an OAuth authentication layer”
Next : merging the PR
Done by a project maintainer (could be you !)
Merge from the PR branch to master
Again : have a clear merge message
→ On Github : 'Closes #56' will close Github issue and links
Congratulations, you're a Github contributor ;-)
Git tools
git-cola (Linux, Win, Mac)
GitHub Desktop (Win, Mac)
GitKraken (Linux, Win, Mac) - beta
Liquid prompt
Useful list :
https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools
Questions ?
Questions ?
Thanks !
@wimgtr
wim@cu.be
Ad

More Related Content

What's hot (20)

An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 
Tornado web
Tornado webTornado web
Tornado web
kurtiss
 
Designing net-aws-glacier
Designing net-aws-glacierDesigning net-aws-glacier
Designing net-aws-glacier
Workhorse Computing
 
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Syncing up with Python’s asyncio for (micro) service development, Joir-dan GumbsSyncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Pôle Systematic Paris-Region
 
Python, async web frameworks, and MongoDB
Python, async web frameworks, and MongoDBPython, async web frameworks, and MongoDB
Python, async web frameworks, and MongoDB
emptysquare
 
Tornado - different Web programming
Tornado - different Web programmingTornado - different Web programming
Tornado - different Web programming
Dima Malenko
 
Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?
Kirill Chebunin
 
Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.
Workhorse Computing
 
Nginx + Tornado = 17k req/s
Nginx + Tornado = 17k req/sNginx + Tornado = 17k req/s
Nginx + Tornado = 17k req/s
moret1979
 
Tornadoweb
TornadowebTornadoweb
Tornadoweb
Osman Yuksel
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
Perl Careers
 
groovy & grails - lecture 13
groovy & grails - lecture 13groovy & grails - lecture 13
groovy & grails - lecture 13
Alexandre Masselot
 
Construire son JDK en 10 étapes
Construire son JDK en 10 étapesConstruire son JDK en 10 étapes
Construire son JDK en 10 étapes
José Paumard
 
Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?
Phil Leggetter
 
Puppet at GitHub - PuppetConf 2013
Puppet at GitHub - PuppetConf 2013Puppet at GitHub - PuppetConf 2013
Puppet at GitHub - PuppetConf 2013
Puppet
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
MongoDB
 
Composer the right way - SunshinePHP
Composer the right way - SunshinePHPComposer the right way - SunshinePHP
Composer the right way - SunshinePHP
Rafael Dohms
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to MissJava Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Andres Almiray
 
groovy & grails - lecture 10
groovy & grails - lecture 10groovy & grails - lecture 10
groovy & grails - lecture 10
Alexandre Masselot
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++
Daniele Pallastrelli
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 
Tornado web
Tornado webTornado web
Tornado web
kurtiss
 
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Syncing up with Python’s asyncio for (micro) service development, Joir-dan GumbsSyncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Syncing up with Python’s asyncio for (micro) service development, Joir-dan Gumbs
Pôle Systematic Paris-Region
 
Python, async web frameworks, and MongoDB
Python, async web frameworks, and MongoDBPython, async web frameworks, and MongoDB
Python, async web frameworks, and MongoDB
emptysquare
 
Tornado - different Web programming
Tornado - different Web programmingTornado - different Web programming
Tornado - different Web programming
Dima Malenko
 
Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?
Kirill Chebunin
 
Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.Shared Object images in Docker: What you need is what you want.
Shared Object images in Docker: What you need is what you want.
Workhorse Computing
 
Nginx + Tornado = 17k req/s
Nginx + Tornado = 17k req/sNginx + Tornado = 17k req/s
Nginx + Tornado = 17k req/s
moret1979
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
Perl Careers
 
Construire son JDK en 10 étapes
Construire son JDK en 10 étapesConstruire son JDK en 10 étapes
Construire son JDK en 10 étapes
José Paumard
 
Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?Real-Time Web Apps & Symfony. What are your options?
Real-Time Web Apps & Symfony. What are your options?
Phil Leggetter
 
Puppet at GitHub - PuppetConf 2013
Puppet at GitHub - PuppetConf 2013Puppet at GitHub - PuppetConf 2013
Puppet at GitHub - PuppetConf 2013
Puppet
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
MongoDB
 
Composer the right way - SunshinePHP
Composer the right way - SunshinePHPComposer the right way - SunshinePHP
Composer the right way - SunshinePHP
Rafael Dohms
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to MissJava Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Andres Almiray
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++
Daniele Pallastrelli
 

Similar to Practical git for developers (20)

Git training
Git trainingGit training
Git training
eric7master
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
Boise Web Technologies Group
 
Using Github for DSpace development
Using Github for DSpace developmentUsing Github for DSpace development
Using Github for DSpace development
Bram Luyten
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
Git
GitGit
Git
Shinu Suresh
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin Ren
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinux
Shubham Verma
 
GitSetupLinux
GitSetupLinuxGitSetupLinux
GitSetupLinux
Shubham Verma
 
Git
GitGit
Git
Hanokh Aloni
 
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
HuthaifaAlmaqrami1
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
PRIYATHAMDARISI
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
Stephen Yeargin
 
Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginning
James Aylett
 
YET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLES
YET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLESYET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLES
YET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLES
removed_7e30d0915f14b559919f338a71e486d1
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
Rifauddin Tsalitsy
 
Git
GitGit
Git
Mayank Patel
 
Version Control Systems Software Engineering
Version Control Systems Software EngineeringVersion Control Systems Software Engineering
Version Control Systems Software Engineering
ssuser1c86e3
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git for developers
Git for developersGit for developers
Git for developers
Hacen Dadda
 
Using Github for DSpace development
Using Github for DSpace developmentUsing Github for DSpace development
Using Github for DSpace development
Bram Luyten
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin Ren
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
PRIYATHAMDARISI
 
Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginning
James Aylett
 
YET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLES
YET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLESYET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLES
YET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLES
removed_7e30d0915f14b559919f338a71e486d1
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
Rifauddin Tsalitsy
 
Version Control Systems Software Engineering
Version Control Systems Software EngineeringVersion Control Systems Software Engineering
Version Control Systems Software Engineering
ssuser1c86e3
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git for developers
Git for developersGit for developers
Git for developers
Hacen Dadda
 
Ad

More from Wim Godden (20)

Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to life
Wim Godden
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8
Wim Godden
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
Wim Godden
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to life
Wim Godden
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
Wim Godden
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.x
Wim Godden
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.x
Wim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
Wim Godden
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to life
Wim Godden
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8
Wim Godden
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
Wim Godden
 
Bringing bright ideas to life
Bringing bright ideas to lifeBringing bright ideas to life
Bringing bright ideas to life
Wim Godden
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
Wim Godden
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.x
Wim Godden
 
The why and how of moving to php 7.x
The why and how of moving to php 7.xThe why and how of moving to php 7.x
The why and how of moving to php 7.x
Wim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
Wim Godden
 
Your app lives on the network - networking for web developers
Your app lives on the network - networking for web developersYour app lives on the network - networking for web developers
Your app lives on the network - networking for web developers
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
Wim Godden
 
Ad

Recently uploaded (20)

Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
 
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
 
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Leading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael JidaelLeading AI Innovation As A Product Manager - Michael Jidael
Leading AI Innovation As A Product Manager - Michael Jidael
Michael Jidael
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Learn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step GuideLearn the Basics of Agile Development: Your Step-by-Step Guide
Learn the Basics of Agile Development: Your Step-by-Step Guide
Marcel David
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 

Practical git for developers

  • 1. Practical git for developers (aka 'Git for beginners') Wim Godden Cu.be Solutions @wimgtr
  • 2. Who am I ? Wim Godden (@wimgtr)
  • 11. Belgium – the traffic
  • 12. Who am I ? Wim Godden (@wimgtr) Founder of Cu.be Solutions (http://cu.be) Open Source developer since 1997 Developer of PHPCompatibility, OpenX, PHPConsistent, ... Speaker at Open Source conferences
  • 13. Who are you ? Developers ? CVS ? SVN ? TFS ? Git ?
  • 14. What is git ? Git is a file system with a Version Control System on top of it
  • 16. What is git ? Git is a file system with a Version Control System on top of it
  • 17. What is git ? Git is a distributed file system with a Version Control System on top of it
  • 18. (Almost) everything is local Clone = copy of entire repository Work offline : Perform a diff View file history Commit changes (!) Create, merge or switch branches etc. Only push/pull are not local
  • 19. (Almost) everything is immutable Immutable = doesn't change Once placed in git, it stays there Even if you delete files
  • 20. Differences with SVN SVN keeps diffs between versions Git keeps full snapshots Commit #1 tree author_info parent Tree README.MD Commit #2 tree author_info parent Tree README.MD index.php Commit #3 tree author_info parent Tree README.MD LICENSE index.php
  • 21. Differences with SVN SVN is centralized ↔ Git is distributed An SVN commit → shared with everyone ↔ A Git commit is local SVN has revision increments ↔ Git has SHA1 hashes to identify objects (commits, trees, blobs, ...)
  • 22. Basic git – config $ git config --global user.name "Wim Godden" $ git config --global user.email "[email protected]" $ git config --global core.editor vim $ git config --global core.autocrlf input $ git config --global core.autocrlf true $ git config --global color.ui true (on Linux) (on Windows)
  • 23. Basic git - .gitignore Allows you to specify files to ignore Can be specific to repository Hint : set up a global .gitignore for : thumbnail.dat desktop.ini .DS_Store Your local editor's files …
  • 24. Create a repo $ git init $ tree .git .git/ ├── branches ├── config ├── description ├── HEAD ├── info │   └── exclude ├── objects │   ├── info │   └── pack └── refs ├── heads └── tags
  • 25. .git directory config – Configuration file refs/heads/... - branches refs/tags/... - tags refs/remotes/... - remotes objects/... - the actual objects HEAD – the current working space, points to one of branches
  • 26. git clone Creates a repository from an existing repository git clone https://someplace.com/repo.git <somefolder> Original repository is called 'origin' → This is called a 'remote'
  • 27. Git flow Working directory Staging area Repository Remote(s) Add Commit Push
  • 28. git status Simple command Explains in clear language what's going on Use it, use it, use it, ...
  • 29. Git flow Working directory Staging area Repository Remote(s) Add Commit Push
  • 30. git add Add file in current state to the staging area Can be new file Can be modification git add -A stages all git add . stages new and modified, but no deletions git add -u stages modified and deleted, but no new files
  • 31. git reset Unstage changes Revert to older commit version Beware : dangerous command !
  • 32. Remove files from repository 2 ways : Delete, then rm Delete the file from working directory git rm <filename> Commit Just rm git rm <filename> Commit Accidentially deleted ? → git checkout -- <filename>
  • 33. Git flow Working directory Staging area Repository Remote(s) Add Commit Push
  • 34. git commit Creates a new version Based on the staging area Commits on local repository only Commit #1 tree author_info parent Tree README.MD Commit #2 tree author_info parent : #1 Tree README.MD index.php Commit #3 tree author_info parent : #2 Tree README.MD LICENSE index.php HEAD
  • 35. git log Shows each commit with SHA1 hash → hash can be used with other commands -p gives a diff view
  • 36. git diff No params : default diff output git diff --staged : diff with what's been staged
  • 37. Clone, add, commit and push C1 Remote originLocal repository C2 master C1 C2 origin/master 1 2 C1 C2 origin/master C3 master HEAD master HEAD1 2 C1 C2 master C1 C2 origin/master C3 master HEAD 3 3 C1 C2 master C3
  • 38. Working with remotes git push → Send locally commited changes to the remote repository git fetch/pull → Retrieve changes from the remote repository
  • 39. Fetch, merge and pull Remote originLocal repository C1 C2 origin/master 1 2 C1 C2 origin/master C3 master HEAD master HEAD 1 C1 C2 C3 master HEAD 2 3 C1 C2 master C3C2 origin/master 3
  • 40. git fetch + merge vs git pull git fetch : fetches information from remote into local repository but nothing more git merge : merges changes that were fetched needs a source parameter merges TO wherever HEAD is pointing to : git merge origin/master git pull : does both at the same time
  • 41. Branches Branches are separate full-blown versions of your code Default branch = master Which branches are there ? → git branch Create a new branch → git branch <branchname> Switch to branch → git checkout <branchname> Create + switch to new branch → git checkout -b <branchname> Show branch activity : git show-branch Delete a branch : git branch -d <branchname>
  • 42. Merging changes in a project C1 C2 origin/master C1 C2 origin/master C3 master master C4 test LICENSE : added paragraph 1 LICENSE : added paragraph 2 C1 C2 origin/master C3 master C4 test LICENSE : added paragraph 1 + 2 Edited LICENSE C5
  • 43. Conflicting change git merge <branchname> → conflict git status → shows conflicted files Resolve conflict git commit -a → tells git conflict was resolved
  • 44. Contributing to a Github project Github is built on Git, so... Clone, commit, pull, merge, push are all the same But : You need to fork the project first Changes to the main repository must be requested through a pull request
  • 46. Creating a fork Will create a complete copy (not a clone) of the project Including master, all branches, all tags, all commits, etc. i.e. confoo/some-repo → <your_github_username>/some-repo You can do anything in it... But please don't if you intend to contribute back... Which you should ofcourse ;-)
  • 47. Next : create a branch for your feature/bugfix Why ? Work on multiple features/fixes at same time Experiment without damaging your master master should always be a fully functioning, deployable version Name the branch well Don't : bugfix Do : bugfix_issue_26_fatal_error
  • 48. Next : add/change code and commit Don't forget unit tests, integration tests, … Make your commit message descriptive Don't : fixed it Do : added real-time updates on dashboard Each commit should contain a single feature or bugfix → Allows project maintainers to add small blocks of code → Easier than adding 50 features/bugfixes → Easier to test
  • 49. Next : create a Pull Request (PR) When you want to contribute Partial code = OK → But only if you want feedback Otherwise : Finish your code Make sure you have unit tests Be descriptive in your pull request Don't : “this will fix my issues” Do : “Added an OAuth authentication layer”
  • 50. Next : merging the PR Done by a project maintainer (could be you !) Merge from the PR branch to master Again : have a clear merge message → On Github : 'Closes #56' will close Github issue and links Congratulations, you're a Github contributor ;-)
  • 51. Git tools git-cola (Linux, Win, Mac) GitHub Desktop (Win, Mac) GitKraken (Linux, Win, Mac) - beta Liquid prompt Useful list : https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools

Editor's Notes

  • #27: git clone [email_address]:wimg/confoodemo.git
  • #42: * = current brach + = commit is in the branch - = commit is in the branch as a merge
  • #44: git checkout -b test edit LICENSE file git checkout master edit LICENSE file git merge test → will show conflict git status → will show unmerged path edit LICENSE file git commit -a -m&amp;apos;conflict resolved&amp;apos;