SlideShare a Scribd company logo
Git, Github and Open Source
About Me

 • Lorna Jane Mitchell

 • Consultant, author, speaker

 • Github: http://github.com/lornajane

 • Twitter: @lornajane

 • Web: http://lornajane.net

 • Project lead of joind.in, open source project




                                                   2
Github

"We make it easier to collaborate with others and share your projects with
the universe"


   • Github is a hosted source control solution, based on git.

   • Used by open source projects, personal projects

   • Paid-for offerings for non-public code


There are other ways to do git, open source, and probably everything
mentioned here ...




                                                                             3
Centralised Version Control

The overall ecosystem with git looks different because instead of this:




                                  repo



      checkout                 checkout                  checkout




                                                                          4
Distributed Version Control

Things look like this:




                                repo


            repo         repo          repo   repo




                                                     5
Distributed Version Control

Or rather:




                     repo

                            repo

              repo

                                   repo

                     repo


                                          6
Code on GitHub
Get a Repo

 • Find the project

 • Fork the project

 • Clone your repo




                      8
Fork the Project




                   9
Clone your Repo




git clone git@github.com:username/joindin.git




                                                10
Git: Many Repos


                  GitHub

             joindin/joind.in

                     fork


            your-user/joind.in


                                clone

                            development
                                          11
Working with Git
Git Overview

A few key commands you will need:

  • git log and git show

  • git status and git diff

  • git add

  • git commit

  • git pull and git push

  • reverting changes


Then we’ll talk about branching




                                    13
Git Log

Git automatically sends the output to a pager like less


commit 76916fed387d9161d48b0f1e592685c183e4757c
Author: Lorna Mitchell <lorna@lornajane.net>
Date:   Wed Mar 14 21:06:24 2012 +0000

    adding the actual announcement wording to the banner

commit 3fdc9f6b9795ed6a3a02465817bfebb8f77ca34e
Author: Kim Rowan <rowan02@unknown-00-25-00-44-3a-04.home>
Date:   Tue Mar 13 12:58:48 2012 +0000

    Added info block to main page announcing php|arch Impact Award nom

commit dc5777199aa2bb822b498ec1dea99f3e89ee90e0
Author: Lorna Mitchell <lorna@lornajane.net>
Date:   Sun Mar 11 21:03:13 2012 +0000

    removed some unused files

                                                                   14
Git Log

There are some alternative views, this is git log -graph -oneline
* 76916fe adding the actual announcement wording to the banner
* 3fdc9f6 Added info block to main page announcing php|arch Impact Awa
* dc57771 removed some unused files
* aa502ec straightening out a problem with API metadata not showing up
* 6719b8a GH #473: Refactored ternary to if
*    d6a69d7 Merge branch 'joindin-167'
|
| * b7effc5 JOINDIN-167: Facebook users without username (this is poss
* | 6af9450 JOINDIN-167: reverted removal of facebook login
* |    6249401 Merge branch 'master' of https://github.com/joindin/join
| 
| |/
|/|
| *    16b31d3 Merge remote-tracking branch 'lornajane/no-facebook'
| |
| | * 36ee9ea removing facebook login functionality - hopefully tempor
| * | f4a2a73 removing references to the gravatar cache; these are ser
| |/
| * 83d6c04 Prevented forwarding on to anywhere except this site after
| *    d411358 Merge remote-tracking branch 'mvriel/JOINDIN-161_2'
                                                                    15
Git Status

Shows you what you have changed, and what will be in your next commit
(these are two different things)

After editing a couple of files:

# On branch impact-banner
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working dir
#
#       modified:   src/.htaccess
#       modified:   src/system/application/views/main/index.php
#
no changes added to commit (use "git add" and/or "git commit -a")


To include changes in a commit, we need to stage them first using
monogit add


                                                                        16
Git Add


git add src/system/application/views/main/index.php


git status again
# On branch impact-banner
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   src/system/application/views/main/index.php
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working dir
#
#       modified:   src/.htaccess
#




                                                                   17
Git Commit

git commit -m ’meaningful commit message’

  • Without the -m, git will open your default text editor to add a message

  • You can also supply a list of files to include in the commit

  • Use git add -interactive to stage sections of files




                                                                              18
Undoing Changes

To undo changes that you haven’t staged yet:

        git checkout -- path/to/file


If you have staged the changes, you can still undo them:

        git reset
        git reset --hard

Reset will unstage the changes; the hard reset puts everything back to the
most recent commit




                                                                             19
Managing the Multiple Repositories
Stay in Sync

Pull the changes from upstream into your local repo



               GitHub

          changes upstream



           your-user/joind.in               pull



                                        development


git pull upstream master

                                                      21
Stay in Sync

The changes are now in your local repo, push them to github:



                  GitHub

             changes upstream



              your-user/joind.in


                                   push

                                      changes locally


git push                                                       22
Branching in Git

What you need to know:

  • Branching (and merging!) are fast and painless




                                                     23
Branching in Git

What you need to know:

  • Branching (and merging!) are fast and painless

  • Branches are private by default




                                                     23
Branching in Git

What you need to know:

  • Branching (and merging!) are fast and painless

  • Branches are private by default

  • Branches are in the repo, they are not copies

      • no updating vhosts
      • only one directory with code in




                                                     23
Git Branching Commands

Create a new branch:

git checkout -b new-branch-name


Switch to an existing branch

git checkout branchname


List branches in this repo

git branch

Branches are local by default, they don’t synchronise to other repositories
unless asked




                                                                              24
Best Practice in Branching

Git doesn’t dictate a process, so usually each project does. Common
features:

  • Branch for features

  • Branch for fixes

  • Branch for experiments




                                                                      25
Best Practice in Branching

Git doesn’t dictate a process, so usually each project does. Common
features:

  • Branch for features

  • Branch for fixes

  • Branch for experiments

  • Basically: branch!

By keeping changes in branches, they are very easy to merge to another
repo or branch




                                                                         25
Sharing Changes

Your changes are in your local branch - how do they get into a main
project?




                  GitHub

                joindin/joind.in



              your-user/joind.in


                                        local feature


                                                                      26
Sharing Changes

git push origin new-branch-name




              GitHub

           joindin/joind.in



           feature at origin


                               push

                                      local feature


                                                      27
Sharing Changes

To offer changes upstream, make a pull request




                  GitHub

               joindin/joind.in

          pull request


               feature at origin



                                      local feature


                                                      28
Making a Pull Request

Make the pull request on GitHub




Explain what you have changed, and why. Keep changes atomic.
                                                               29
Open Source Contributions

After that:

   • Your pull request appears on the project’s list

        • http://github.com/joindin/joind.in/pulls

   • Hopefully it gets merged

   • You get bragging rights :)

        • https://github.com/joindin/joind.in/contributors




                                                             30
Where to Begin with Open Source

How to get involved: (warning, contains bias!)

   • Check for introductory docs

       • http://joind.in/about




                                                 31
Where to Begin with Open Source

How to get involved: (warning, contains bias!)

   • Check for introductory docs

       • http://joind.in/about

   • Get code and set up the project

       • usually, fork the repo and read the README




                                                      31
Where to Begin with Open Source

How to get involved: (warning, contains bias!)

   • Check for introductory docs

       • http://joind.in/about

   • Get code and set up the project

       • usually, fork the repo and read the README

   • Find the bug tracker, and pick something

       • http://joindin.jira.com




                                                      31
Where to Begin with Open Source

How to get involved: (warning, contains bias!)

   • Check for introductory docs

       • http://joind.in/about

   • Get code and set up the project

       • usually, fork the repo and read the README

   • Find the bug tracker, and pick something

       • http://joindin.jira.com

   • Talk to the other people in the project

       • #joind.in on freenode


                                                      31
Where to Begin with Open Source

How to get involved: (warning, contains bias!)

   • Check for introductory docs

       • http://joind.in/about

   • Get code and set up the project

       • usually, fork the repo and read the README

   • Find the bug tracker, and pick something

       • http://joindin.jira.com

   • Talk to the other people in the project

       • #joind.in on freenode

   • Share and enjoy
                                                      31
Questions?
Thanks!

  • Slides will be on slideshare

  • Github: http://github.com/lornajane

  • Twitter: @lornajane

  • Web: http://lornajane.net


PHPNW - 3rd April, Derick Rethans on MongoDB. Rain Bar, Manchester.




                                                                      33

More Related Content

What's hot (20)

PPTX
Github basics
Radoslav Georgiev
 
PPTX
Intro to Git and GitHub
Uri Goldstein
 
PDF
Inside GitHub
err
 
PPTX
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
PDF
git and github
Darren Oakley
 
PDF
Getting Started with GitHub
Michael Redlich
 
PPTX
Git and Github Session
GoogleDevelopersStud1
 
PDF
Introduction to Git and Github
Houari ZEGAI
 
PDF
Starting with Git & GitHub
Nicolás Tourné
 
PPTX
Workshop on Git and GitHub
DSCVSSUT
 
PDF
Git and GitHub crash course
Mireia Sangalo
 
PDF
Git & GitHub for Beginners
Sébastien Saunier
 
PPTX
Git tutorial
TingYen Lee
 
PPTX
HacktoberFest-Git&GitHub
GDSCIIITBbsr
 
PPTX
Git 101
jayrparro
 
PPTX
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Rueful Robin
 
PPT
Git basic
Emran Ul Hadi
 
PPT
Git101
Jason Noble
 
PPTX
Introduction to git administration
Shawn Doyle
 
PPT
Git Introduction
Anil Wadghule
 
Github basics
Radoslav Georgiev
 
Intro to Git and GitHub
Uri Goldstein
 
Inside GitHub
err
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
git and github
Darren Oakley
 
Getting Started with GitHub
Michael Redlich
 
Git and Github Session
GoogleDevelopersStud1
 
Introduction to Git and Github
Houari ZEGAI
 
Starting with Git & GitHub
Nicolás Tourné
 
Workshop on Git and GitHub
DSCVSSUT
 
Git and GitHub crash course
Mireia Sangalo
 
Git & GitHub for Beginners
Sébastien Saunier
 
Git tutorial
TingYen Lee
 
HacktoberFest-Git&GitHub
GDSCIIITBbsr
 
Git 101
jayrparro
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Rueful Robin
 
Git basic
Emran Ul Hadi
 
Git101
Jason Noble
 
Introduction to git administration
Shawn Doyle
 
Git Introduction
Anil Wadghule
 

Viewers also liked (8)

PDF
Git/GitHub
Microsoft
 
PDF
Inside GitHub with Chris Wanstrath
SV Ruby on Rails Meetup
 
PPTX
Introduction to Git and GitHub
Bioinformatics and Computational Biosciences Branch
 
PDF
Git and Github
Wen-Tien Chang
 
KEY
Git and GitHub
James Gray
 
PPTX
Introduction to Git/Github - A beginner's guide
Rohit Arora
 
PDF
Git 101: Git and GitHub for Beginners
HubSpot
 
PDF
Quick Introduction to git
Joel Krebs
 
Git/GitHub
Microsoft
 
Inside GitHub with Chris Wanstrath
SV Ruby on Rails Meetup
 
Git and Github
Wen-Tien Chang
 
Git and GitHub
James Gray
 
Introduction to Git/Github - A beginner's guide
Rohit Arora
 
Git 101: Git and GitHub for Beginners
HubSpot
 
Quick Introduction to git
Joel Krebs
 
Ad

Similar to Git, GitHub and Open Source (20)

KEY
Git Tech Talk
Chris Johnson
 
PPTX
Git and GitHub
Priya Nayak
 
ODP
Git tech talk
razasayed
 
PPTX
Git and GitHub (1).pptx
BetelAddisu
 
PDF
Git basics
GHARSALLAH Mohamed
 
PDF
Git basics
Amit Sawhney
 
PPTX
Git and GitHub Workshop of GDG on Campus UNSTPB
AmaraCostachiu
 
PDF
Advanced Git Tutorial
Sage Sharp
 
PPTX
Git Session 2K23.pptx
Eshaan35
 
PPTX
Session git
Roni Saha
 
KEY
Introduction to Git
Lukas Fittl
 
PDF
Understanding Distributed Source Control
Lorna Mitchell
 
PPT
Getting started with GIT
pratz0909
 
PPTX
github ppt git ppt on git hub to know ab
infoinnext
 
PDF
Git training
eric7master
 
PPTX
Git and github fundamentals
RajKharvar
 
KEY
Introduction To Git
Arnaud Seilles
 
PPTX
tech winter break workshop on git &git hub.pptx
ashishraulin
 
PPTX
Intro to Git and Github
Andrew Babiec
 
PPT
Effective Git with Eclipse
Chris Aniszczyk
 
Git Tech Talk
Chris Johnson
 
Git and GitHub
Priya Nayak
 
Git tech talk
razasayed
 
Git and GitHub (1).pptx
BetelAddisu
 
Git basics
GHARSALLAH Mohamed
 
Git basics
Amit Sawhney
 
Git and GitHub Workshop of GDG on Campus UNSTPB
AmaraCostachiu
 
Advanced Git Tutorial
Sage Sharp
 
Git Session 2K23.pptx
Eshaan35
 
Session git
Roni Saha
 
Introduction to Git
Lukas Fittl
 
Understanding Distributed Source Control
Lorna Mitchell
 
Getting started with GIT
pratz0909
 
github ppt git ppt on git hub to know ab
infoinnext
 
Git training
eric7master
 
Git and github fundamentals
RajKharvar
 
Introduction To Git
Arnaud Seilles
 
tech winter break workshop on git &git hub.pptx
ashishraulin
 
Intro to Git and Github
Andrew Babiec
 
Effective Git with Eclipse
Chris Aniszczyk
 
Ad

More from Lorna Mitchell (20)

PDF
OAuth: Trust Issues
Lorna Mitchell
 
PDF
Web Services PHP Tutorial
Lorna Mitchell
 
PDF
Best Practice in API Design
Lorna Mitchell
 
PDF
Business 101 for Developers: Time and Money
Lorna Mitchell
 
ODP
Things I wish web graduates knew
Lorna Mitchell
 
PDF
Teach a Man To Fish (phpconpl edition)
Lorna Mitchell
 
PDF
Web services tutorial
Lorna Mitchell
 
ODP
Join In With Joind.In
Lorna Mitchell
 
PDF
Tool Up Your LAMP Stack
Lorna Mitchell
 
PDF
Going Freelance
Lorna Mitchell
 
PDF
Best Practice in Web Service Design
Lorna Mitchell
 
PDF
Coaching Development Teams: Teach A Man To Fish
Lorna Mitchell
 
PDF
Zend Certification Preparation Tutorial
Lorna Mitchell
 
PDF
Implementing OAuth with PHP
Lorna Mitchell
 
PDF
Web Services Tutorial
Lorna Mitchell
 
PDF
Object Oriented Programming in PHP
Lorna Mitchell
 
PDF
Example Presentation
Lorna Mitchell
 
PDF
Could You Telecommute?
Lorna Mitchell
 
PDF
Design Patterns
Lorna Mitchell
 
PDF
Running a Project with Github
Lorna Mitchell
 
OAuth: Trust Issues
Lorna Mitchell
 
Web Services PHP Tutorial
Lorna Mitchell
 
Best Practice in API Design
Lorna Mitchell
 
Business 101 for Developers: Time and Money
Lorna Mitchell
 
Things I wish web graduates knew
Lorna Mitchell
 
Teach a Man To Fish (phpconpl edition)
Lorna Mitchell
 
Web services tutorial
Lorna Mitchell
 
Join In With Joind.In
Lorna Mitchell
 
Tool Up Your LAMP Stack
Lorna Mitchell
 
Going Freelance
Lorna Mitchell
 
Best Practice in Web Service Design
Lorna Mitchell
 
Coaching Development Teams: Teach A Man To Fish
Lorna Mitchell
 
Zend Certification Preparation Tutorial
Lorna Mitchell
 
Implementing OAuth with PHP
Lorna Mitchell
 
Web Services Tutorial
Lorna Mitchell
 
Object Oriented Programming in PHP
Lorna Mitchell
 
Example Presentation
Lorna Mitchell
 
Could You Telecommute?
Lorna Mitchell
 
Design Patterns
Lorna Mitchell
 
Running a Project with Github
Lorna Mitchell
 

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 

Git, GitHub and Open Source

  • 1. Git, Github and Open Source
  • 2. About Me • Lorna Jane Mitchell • Consultant, author, speaker • Github: http://github.com/lornajane • Twitter: @lornajane • Web: http://lornajane.net • Project lead of joind.in, open source project 2
  • 3. Github "We make it easier to collaborate with others and share your projects with the universe" • Github is a hosted source control solution, based on git. • Used by open source projects, personal projects • Paid-for offerings for non-public code There are other ways to do git, open source, and probably everything mentioned here ... 3
  • 4. Centralised Version Control The overall ecosystem with git looks different because instead of this: repo checkout checkout checkout 4
  • 5. Distributed Version Control Things look like this: repo repo repo repo repo 5
  • 6. Distributed Version Control Or rather: repo repo repo repo repo 6
  • 8. Get a Repo • Find the project • Fork the project • Clone your repo 8
  • 10. Clone your Repo git clone [email protected]:username/joindin.git 10
  • 11. Git: Many Repos GitHub joindin/joind.in fork your-user/joind.in clone development 11
  • 13. Git Overview A few key commands you will need: • git log and git show • git status and git diff • git add • git commit • git pull and git push • reverting changes Then we’ll talk about branching 13
  • 14. Git Log Git automatically sends the output to a pager like less commit 76916fed387d9161d48b0f1e592685c183e4757c Author: Lorna Mitchell <[email protected]> Date: Wed Mar 14 21:06:24 2012 +0000 adding the actual announcement wording to the banner commit 3fdc9f6b9795ed6a3a02465817bfebb8f77ca34e Author: Kim Rowan <[email protected]> Date: Tue Mar 13 12:58:48 2012 +0000 Added info block to main page announcing php|arch Impact Award nom commit dc5777199aa2bb822b498ec1dea99f3e89ee90e0 Author: Lorna Mitchell <[email protected]> Date: Sun Mar 11 21:03:13 2012 +0000 removed some unused files 14
  • 15. Git Log There are some alternative views, this is git log -graph -oneline * 76916fe adding the actual announcement wording to the banner * 3fdc9f6 Added info block to main page announcing php|arch Impact Awa * dc57771 removed some unused files * aa502ec straightening out a problem with API metadata not showing up * 6719b8a GH #473: Refactored ternary to if * d6a69d7 Merge branch 'joindin-167' | | * b7effc5 JOINDIN-167: Facebook users without username (this is poss * | 6af9450 JOINDIN-167: reverted removal of facebook login * | 6249401 Merge branch 'master' of https://github.com/joindin/join | | |/ |/| | * 16b31d3 Merge remote-tracking branch 'lornajane/no-facebook' | | | | * 36ee9ea removing facebook login functionality - hopefully tempor | * | f4a2a73 removing references to the gravatar cache; these are ser | |/ | * 83d6c04 Prevented forwarding on to anywhere except this site after | * d411358 Merge remote-tracking branch 'mvriel/JOINDIN-161_2' 15
  • 16. Git Status Shows you what you have changed, and what will be in your next commit (these are two different things) After editing a couple of files: # On branch impact-banner # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working dir # # modified: src/.htaccess # modified: src/system/application/views/main/index.php # no changes added to commit (use "git add" and/or "git commit -a") To include changes in a commit, we need to stage them first using monogit add 16
  • 17. Git Add git add src/system/application/views/main/index.php git status again # On branch impact-banner # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: src/system/application/views/main/index.php # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working dir # # modified: src/.htaccess # 17
  • 18. Git Commit git commit -m ’meaningful commit message’ • Without the -m, git will open your default text editor to add a message • You can also supply a list of files to include in the commit • Use git add -interactive to stage sections of files 18
  • 19. Undoing Changes To undo changes that you haven’t staged yet: git checkout -- path/to/file If you have staged the changes, you can still undo them: git reset git reset --hard Reset will unstage the changes; the hard reset puts everything back to the most recent commit 19
  • 20. Managing the Multiple Repositories
  • 21. Stay in Sync Pull the changes from upstream into your local repo GitHub changes upstream your-user/joind.in pull development git pull upstream master 21
  • 22. Stay in Sync The changes are now in your local repo, push them to github: GitHub changes upstream your-user/joind.in push changes locally git push 22
  • 23. Branching in Git What you need to know: • Branching (and merging!) are fast and painless 23
  • 24. Branching in Git What you need to know: • Branching (and merging!) are fast and painless • Branches are private by default 23
  • 25. Branching in Git What you need to know: • Branching (and merging!) are fast and painless • Branches are private by default • Branches are in the repo, they are not copies • no updating vhosts • only one directory with code in 23
  • 26. Git Branching Commands Create a new branch: git checkout -b new-branch-name Switch to an existing branch git checkout branchname List branches in this repo git branch Branches are local by default, they don’t synchronise to other repositories unless asked 24
  • 27. Best Practice in Branching Git doesn’t dictate a process, so usually each project does. Common features: • Branch for features • Branch for fixes • Branch for experiments 25
  • 28. Best Practice in Branching Git doesn’t dictate a process, so usually each project does. Common features: • Branch for features • Branch for fixes • Branch for experiments • Basically: branch! By keeping changes in branches, they are very easy to merge to another repo or branch 25
  • 29. Sharing Changes Your changes are in your local branch - how do they get into a main project? GitHub joindin/joind.in your-user/joind.in local feature 26
  • 30. Sharing Changes git push origin new-branch-name GitHub joindin/joind.in feature at origin push local feature 27
  • 31. Sharing Changes To offer changes upstream, make a pull request GitHub joindin/joind.in pull request feature at origin local feature 28
  • 32. Making a Pull Request Make the pull request on GitHub Explain what you have changed, and why. Keep changes atomic. 29
  • 33. Open Source Contributions After that: • Your pull request appears on the project’s list • http://github.com/joindin/joind.in/pulls • Hopefully it gets merged • You get bragging rights :) • https://github.com/joindin/joind.in/contributors 30
  • 34. Where to Begin with Open Source How to get involved: (warning, contains bias!) • Check for introductory docs • http://joind.in/about 31
  • 35. Where to Begin with Open Source How to get involved: (warning, contains bias!) • Check for introductory docs • http://joind.in/about • Get code and set up the project • usually, fork the repo and read the README 31
  • 36. Where to Begin with Open Source How to get involved: (warning, contains bias!) • Check for introductory docs • http://joind.in/about • Get code and set up the project • usually, fork the repo and read the README • Find the bug tracker, and pick something • http://joindin.jira.com 31
  • 37. Where to Begin with Open Source How to get involved: (warning, contains bias!) • Check for introductory docs • http://joind.in/about • Get code and set up the project • usually, fork the repo and read the README • Find the bug tracker, and pick something • http://joindin.jira.com • Talk to the other people in the project • #joind.in on freenode 31
  • 38. Where to Begin with Open Source How to get involved: (warning, contains bias!) • Check for introductory docs • http://joind.in/about • Get code and set up the project • usually, fork the repo and read the README • Find the bug tracker, and pick something • http://joindin.jira.com • Talk to the other people in the project • #joind.in on freenode • Share and enjoy 31
  • 40. Thanks! • Slides will be on slideshare • Github: http://github.com/lornajane • Twitter: @lornajane • Web: http://lornajane.net PHPNW - 3rd April, Derick Rethans on MongoDB. Rain Bar, Manchester. 33