Skip to content

Latest commit

 

History

History
241 lines (161 loc) · 4.67 KB

github.mkd

File metadata and controls

241 lines (161 loc) · 4.67 KB

name: inverse layout: true class: center, middle, inverse


Working with GitHub

Radovan Bast

Licensed under CC BY 4.0. Code examples: OSI-approved MIT license.


layout: false

This talk is a live demo, list below serves as memory help

  • Over 3 million users
  • Over 10 million repositories
  • Largest code host in the world
  • Today the de facto standard
  • GitHub activity good for your CV
  • Overview
  • Creating and deleting projects
  • Accessing projects (https or ssh)
  • README.md
  • Issues (tickets)
  • Wiki
  • Fork/pull-request mechanism: like peer review
  • Autoclosing issues
  • Discussing with mentions
  • GitHub Pages
  • Hooks
  • Gist
  • KTH has GitHub Enterprise

Forking a repository

  • A fork is basically a (bare) clone
  • The upstream repo and the fork are in principle independent repositories
  • We copy all commits, all branches

https://github.com/foo/foo.git

https://github.com/user/foo.git


Cloning a fork to work on it

$ git clone https://github.com/user/foo.git

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Working with the local repo

  • We do some work and make a commit

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Pushing the change to origin

$ git push origin master

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Pull-request

  • We can file a pull-request
  • A pull-request means: "please review my changes and if you agree, merge them with a mouseclick"

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Pull-request

  • If the pull-request is accepted, the change is incorporated

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Updating the fork with upstream changes

  • Upstream repo receives other changes (other merged pull-requests)
  • How do we get these changes to the forked repo?

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Updating the fork with upstream changes

$ git remote add upstream https://github.com/foo/foo.git
$ git fetch upstream

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Updating the fork with upstream changes

$ git checkout master
$ git merge upstream/master

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Updating the fork with upstream changes

$ git push origin master

https://github.com/foo/foo.git

https://github.com/user/foo.git

local repo


Pro-tip

  • Different URLs for fetch and push
$ git remote add origin https://github.com/foo/foo.git
$ git remote set-url --push origin https://github.com/user/foo.git
  • Now we always fetch from the central repo and push to forked repo
$ git remote -v

origin	https://github.com/foo/foo.git (fetch)
origin	https://github.com/user/foo.git (push)

Summary

  • Working with multiple remotes is not scary
  • origin and upstream are just aliases
  • We can call these aliases as we like
  • We can add and remove remotes
$ git remote add upstream https://github.com/foo/foo.git
$ git remote rm upstream
  • We synchronize remotes via the local clone
  • To see all remotes
$ git remote -v