SlideShare a Scribd company logo
1 of 27
GIT
Some tips so we “GIT” it better then before...
WHO AM I?
@glamorous_be

- PHP Developer (@kohanaphp)
- jQuery lover
- GIT freak

- Founder @eidtickets
- Owner Glamorous.be
- President @jongvldwaregem    Jonas De Smet (°86)
A little background
I learned git because of @kohanaphp his switch to git
... and with the love from @github
If you don’t have a @github account yet, then this talk isn’t for you...
... and with the love from @github
If you don’t have a @github account yet, then this talk isn’t for you...
5 MUST-DO’s as git user
   or you would better not start using git at all...
1. Don’t use a GUI, ever! CLI ftw!

• You   will never feel the power of GIT

• Not   (almost) every command is possible through a GUI



 OK, there are cool GUI’s but becoming an expert is easier the
 hard way, the CLI-way!
2. Configure git like it should be...
•$   git config --global color.ui true

•$   git config --global format.pretty oneline

•$ git config --global core.autocrlf true (Windows)
 $ git config --global core.safecrlf true (Windows)
 $ git config --global core.autocrl input (OSX & linux)

•$ git config --global core.excludesfile ~/.gitignore
 $ printf ".DS_StorenThumbs.dbn._*n" >> ~/.gitignore

• enable   bash autocompletion (Google it for your OS)
2. Configure git like it should be...
•$   git config --global color.ui true

•$   git config --global format.pretty oneline

•$ git config --global core.autocrlf true (Windows) use a
                                               LF
 $ git config --global core.safecrlf true (Windows) line lways
                                                       end
 $ git config --global core.autocrl input (OSX & linux)     ing
                                                               s!
•$ git config --global core.excludesfile ~/.gitignore
 $ printf ".DS_StorenThumbs.dbn._*n" >> ~/.gitignore

• enable   bash autocompletion (Google it for your OS)
2. Configure git like it should be...
•$   git config --global color.ui true

•$   git config --global format.pretty oneline

•$ git config --global core.autocrlf true (Windows) use a
                                               LF
 $ git config --global core.safecrlf true (Windows) line lways
                                                       end
 $ git config --global core.autocrl input (OSX & linux)     ing
                                                               s!
•$ git config --global core.excludesfile ~/.gitignore  DR
                                                        Y
 $ printf ".DS_StorenThumbs.dbn._*n" >> ~/.gitignore

• enable   bash autocompletion (Google it for your OS)
3. Use a remote repo if possible




                 and probably many more...
4. Use submodules when possible

• Better   overview of different “parts” in your code

• DRY: Re-use    repositories in every project trough submodules



 Good example: Every module in the @kohanaphp framework is a
 seperate repository, so different contributors and releases possible
5. Branch, branch and tag!
     Choose your own workflow




          Source: http://nvie.com/posts/a-successful-git-branching-model/
5 TIPS that will reduce
the amount of WTF’s
and hopefully making you commit better then before
1. Where’s my commit?
             Oh no! It’s on a detached HEAD?!

•A   problem with submodules “currently not on a branch”

• Search for your commits SHA-reference (eg. a8e358c)
 $ git log -p

• Merge  it with your branch
 $ git checkout master
 $ git merge a8e358c
2. Use git merge --no-ff
You will not regret it if you want to revert it!




                Source: http://nvie.com/posts/a-successful-git-branching-model/
3. Use git add -i
Becomes sometime you do different things together...
4. git submodule rm exists, right?
4. git submodule rm exists, right?


                  No!
$ vim .gitmodules
$ vim .git/config
$ git rm --cached path/to/module   NO trailing slash!

Commit your changes
5. I didn’t change my file but still...
           git tracks file execution permissions too
 2 Possibilities:

• Track no permissions
 $ git config core.fileMode false

• Apply the permissions to the files without have it in your repo
 $ git diff -p 
       | grep -E '^(diff|old mode|new mode)' 
       | sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' 
       | git apply
How to become an
     expert?
... read some resources

• Pro   Git book: http://progit.org/book/

• Github    help: http://gitref.org & http://help.github.com

• Git   manual: http://www.kernel.org/pub/software/scm/git/docs

• Git   screencasts: http://gitcasts.com/

• Git   ready: http://gitready.com/
... and use it, every day!
Q&A    Follow me at @glamorous_be
    Fork me on github.com/glamorous
Some links on delicious.com/glamorous_be/git

More Related Content

What's hot

What's hot (20)

maksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your cimaksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your ci
 
SCM Gitlab Advanced
SCM Gitlab AdvancedSCM Gitlab Advanced
SCM Gitlab Advanced
 
Ktor 101 (以 Ktor 實作 Website 範例)
Ktor 101 (以 Ktor 實作 Website 範例)Ktor 101 (以 Ktor 實作 Website 範例)
Ktor 101 (以 Ktor 實作 Website 範例)
 
ZSH and RVM
ZSH and RVMZSH and RVM
ZSH and RVM
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG Antwerp
 
Git hooks
Git hooksGit hooks
Git hooks
 
Git hooks for front end developers
Git hooks for front end developersGit hooks for front end developers
Git hooks for front end developers
 
Collaboration With Git and GitHub
Collaboration With Git and GitHubCollaboration With Git and GitHub
Collaboration With Git and GitHub
 
C初心者がbyebugにPR出した話
C初心者がbyebugにPR出した話C初心者がbyebugにPR出した話
C初心者がbyebugにPR出した話
 
APIテストあれこれ
APIテストあれこれAPIテストあれこれ
APIテストあれこれ
 
Git hooks
Git hooksGit hooks
Git hooks
 
Git session day 2
Git session day 2Git session day 2
Git session day 2
 
Git! Why? How?
Git! Why? How?Git! Why? How?
Git! Why? How?
 
Golang preso
Golang presoGolang preso
Golang preso
 
SouthEast LinuxFest 2015 - intro to git
SouthEast LinuxFest 2015 -  intro to gitSouthEast LinuxFest 2015 -  intro to git
SouthEast LinuxFest 2015 - intro to git
 
CRuby_Committers_Whos_Who_in_2014
CRuby_Committers_Whos_Who_in_2014CRuby_Committers_Whos_Who_in_2014
CRuby_Committers_Whos_Who_in_2014
 
ChatOps meetup: les humains parlent aux robots
ChatOps meetup: les humains parlent aux robotsChatOps meetup: les humains parlent aux robots
ChatOps meetup: les humains parlent aux robots
 
Git session day 1
Git session day 1Git session day 1
Git session day 1
 
Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 

Similar to Git - Some tips to do it better

Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From Git
Chris Miller
 
Untangling fall2017 week2_try2
Untangling fall2017 week2_try2Untangling fall2017 week2_try2
Untangling fall2017 week2_try2
Derek Jacoby
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
Victor Wong
 

Similar to Git - Some tips to do it better (20)

Git presentation
Git presentationGit presentation
Git presentation
 
Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From Git
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Github basics
Github basicsGithub basics
Github basics
 
Untangling fall2017 week2
Untangling fall2017 week2Untangling fall2017 week2
Untangling fall2017 week2
 
Untangling fall2017 week2_try2
Untangling fall2017 week2_try2Untangling fall2017 week2_try2
Untangling fall2017 week2_try2
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Advanted git
Advanted git Advanted git
Advanted git
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
git and github
git and githubgit and github
git and github
 
Git Obstacle Course: Stop BASHing your head and break down the basics
Git Obstacle Course: Stop BASHing your head and break down the basicsGit Obstacle Course: Stop BASHing your head and break down the basics
Git Obstacle Course: Stop BASHing your head and break down the basics
 
Bedjango talk about Git & GitHub
Bedjango talk about Git & GitHubBedjango talk about Git & GitHub
Bedjango talk about Git & GitHub
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Basic git
Basic gitBasic git
Basic git
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
The hacker choice
The hacker choiceThe hacker choice
The hacker choice
 
Pimp my dev box (Friday Training at Itnig)
Pimp my dev box (Friday Training at Itnig)Pimp my dev box (Friday Training at Itnig)
Pimp my dev box (Friday Training at Itnig)
 

Recently uploaded

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Git - Some tips to do it better

  • 1. GIT Some tips so we “GIT” it better then before...
  • 2. WHO AM I? @glamorous_be - PHP Developer (@kohanaphp) - jQuery lover - GIT freak - Founder @eidtickets - Owner Glamorous.be - President @jongvldwaregem Jonas De Smet (°86)
  • 3. A little background I learned git because of @kohanaphp his switch to git
  • 4. ... and with the love from @github If you don’t have a @github account yet, then this talk isn’t for you...
  • 5. ... and with the love from @github If you don’t have a @github account yet, then this talk isn’t for you...
  • 6. 5 MUST-DO’s as git user or you would better not start using git at all...
  • 7. 1. Don’t use a GUI, ever! CLI ftw! • You will never feel the power of GIT • Not (almost) every command is possible through a GUI OK, there are cool GUI’s but becoming an expert is easier the hard way, the CLI-way!
  • 8. 2. Configure git like it should be... •$ git config --global color.ui true •$ git config --global format.pretty oneline •$ git config --global core.autocrlf true (Windows) $ git config --global core.safecrlf true (Windows) $ git config --global core.autocrl input (OSX & linux) •$ git config --global core.excludesfile ~/.gitignore $ printf ".DS_StorenThumbs.dbn._*n" >> ~/.gitignore • enable bash autocompletion (Google it for your OS)
  • 9. 2. Configure git like it should be... •$ git config --global color.ui true •$ git config --global format.pretty oneline •$ git config --global core.autocrlf true (Windows) use a LF $ git config --global core.safecrlf true (Windows) line lways end $ git config --global core.autocrl input (OSX & linux) ing s! •$ git config --global core.excludesfile ~/.gitignore $ printf ".DS_StorenThumbs.dbn._*n" >> ~/.gitignore • enable bash autocompletion (Google it for your OS)
  • 10. 2. Configure git like it should be... •$ git config --global color.ui true •$ git config --global format.pretty oneline •$ git config --global core.autocrlf true (Windows) use a LF $ git config --global core.safecrlf true (Windows) line lways end $ git config --global core.autocrl input (OSX & linux) ing s! •$ git config --global core.excludesfile ~/.gitignore DR Y $ printf ".DS_StorenThumbs.dbn._*n" >> ~/.gitignore • enable bash autocompletion (Google it for your OS)
  • 11. 3. Use a remote repo if possible and probably many more...
  • 12. 4. Use submodules when possible • Better overview of different “parts” in your code • DRY: Re-use repositories in every project trough submodules Good example: Every module in the @kohanaphp framework is a seperate repository, so different contributors and releases possible
  • 13.
  • 14.
  • 15.
  • 16. 5. Branch, branch and tag! Choose your own workflow Source: http://nvie.com/posts/a-successful-git-branching-model/
  • 17. 5 TIPS that will reduce the amount of WTF’s and hopefully making you commit better then before
  • 18. 1. Where’s my commit? Oh no! It’s on a detached HEAD?! •A problem with submodules “currently not on a branch” • Search for your commits SHA-reference (eg. a8e358c) $ git log -p • Merge it with your branch $ git checkout master $ git merge a8e358c
  • 19. 2. Use git merge --no-ff You will not regret it if you want to revert it! Source: http://nvie.com/posts/a-successful-git-branching-model/
  • 20. 3. Use git add -i Becomes sometime you do different things together...
  • 21. 4. git submodule rm exists, right?
  • 22. 4. git submodule rm exists, right? No! $ vim .gitmodules $ vim .git/config $ git rm --cached path/to/module NO trailing slash! Commit your changes
  • 23. 5. I didn’t change my file but still... git tracks file execution permissions too 2 Possibilities: • Track no permissions $ git config core.fileMode false • Apply the permissions to the files without have it in your repo $ git diff -p | grep -E '^(diff|old mode|new mode)' | sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' | git apply
  • 24. How to become an expert?
  • 25. ... read some resources • Pro Git book: http://progit.org/book/ • Github help: http://gitref.org & http://help.github.com • Git manual: http://www.kernel.org/pub/software/scm/git/docs • Git screencasts: http://gitcasts.com/ • Git ready: http://gitready.com/
  • 26. ... and use it, every day!
  • 27. Q&A Follow me at @glamorous_be Fork me on github.com/glamorous Some links on delicious.com/glamorous_be/git

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n