• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Git, GitHub and Open Source
 

Git, GitHub and Open Source

on

  • 2,714 views

How to get involved with an open source project using github. Shows the process of forking and cloning, a bit of a git primer, and how to submit pull requests. Also how to approach and contribute to ...

How to get involved with an open source project using github. Shows the process of forking and cloning, a bit of a git primer, and how to submit pull requests. Also how to approach and contribute to an open source project.

Statistics

Views

Total Views
2,714
Views on SlideShare
1,853
Embed Views
861

Actions

Likes
3
Downloads
50
Comments
0

1 Embed 861

http://www.lornajane.net 861

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Git, GitHub and Open Source Git, GitHub and Open Source Presentation Transcript

    • 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 withthe universe" • Github is a hosted source control solution, based on git. • Used by open source projects, personal projects • Paid-for offerings for non-public codeThere are other ways to do git, open source, and probably everythingmentioned here ... 3
    • Centralised Version ControlThe overall ecosystem with git looks different because instead of this: repo checkout checkout checkout 4
    • Distributed Version ControlThings look like this: repo repo repo repo repo 5
    • Distributed Version ControlOr 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 Repogit 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 OverviewA 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 changesThen we’ll talk about branching 13
    • Git LogGit automatically sends the output to a pager like lesscommit 76916fed387d9161d48b0f1e592685c183e4757cAuthor: Lorna Mitchell <lorna@lornajane.net>Date: Wed Mar 14 21:06:24 2012 +0000 adding the actual announcement wording to the bannercommit 3fdc9f6b9795ed6a3a02465817bfebb8f77ca34eAuthor: 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 nomcommit dc5777199aa2bb822b498ec1dea99f3e89ee90e0Author: Lorna Mitchell <lorna@lornajane.net>Date: Sun Mar 11 21:03:13 2012 +0000 removed some unused files 14
    • Git LogThere 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 StatusShows 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 usingmonogit add 16
    • Git Addgit add src/system/application/views/main/index.phpgit 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 Commitgit 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 ChangesTo undo changes that you haven’t staged yet: git checkout -- path/to/fileIf you have staged the changes, you can still undo them: git reset git reset --hardReset will unstage the changes; the hard reset puts everything back to themost recent commit 19
    • Managing the Multiple Repositories
    • Stay in SyncPull the changes from upstream into your local repo GitHub changes upstream your-user/joind.in pull developmentgit pull upstream master 21
    • Stay in SyncThe changes are now in your local repo, push them to github: GitHub changes upstream your-user/joind.in push changes locallygit push 22
    • Branching in GitWhat you need to know: • Branching (and merging!) are fast and painless 23
    • Branching in GitWhat you need to know: • Branching (and merging!) are fast and painless • Branches are private by default 23
    • Branching in GitWhat 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 CommandsCreate a new branch:git checkout -b new-branch-nameSwitch to an existing branchgit checkout branchnameList branches in this repogit branchBranches are local by default, they don’t synchronise to other repositoriesunless asked 24
    • Best Practice in BranchingGit doesn’t dictate a process, so usually each project does. Commonfeatures: • Branch for features • Branch for fixes • Branch for experiments 25
    • Best Practice in BranchingGit doesn’t dictate a process, so usually each project does. Commonfeatures: • Branch for features • Branch for fixes • Branch for experiments • Basically: branch!By keeping changes in branches, they are very easy to merge to anotherrepo or branch 25
    • Sharing ChangesYour changes are in your local branch - how do they get into a mainproject? GitHub joindin/joind.in your-user/joind.in local feature 26
    • Sharing Changesgit push origin new-branch-name GitHub joindin/joind.in feature at origin push local feature 27
    • Sharing ChangesTo offer changes upstream, make a pull request GitHub joindin/joind.in pull request feature at origin local feature 28
    • Making a Pull RequestMake the pull request on GitHubExplain what you have changed, and why. Keep changes atomic. 29
    • Open Source ContributionsAfter 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 SourceHow to get involved: (warning, contains bias!) • Check for introductory docs • http://joind.in/about 31
    • Where to Begin with Open SourceHow 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 SourceHow 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 SourceHow 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 SourceHow 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.netPHPNW - 3rd April, Derick Rethans on MongoDB. Rain Bar, Manchester. 33