ten things you didn't know git and github could do

36
Ten Things You Didn't Know Git And GitHub Could Do Owen Ou @JingwenOwenOu http://owenou.com/2012/01/13/ten-things-you-didnt- know-git-and-github-could-do.html Saturday, 19 January, 13

Upload: owen-ou

Post on 15-May-2015

1.218 views

Category:

Technology


1 download

TRANSCRIPT

Page 2: Ten Things You Didn't Know Git And GitHub Could Do

Agenda

• 10 GitHub tricks

• Demo of GitHub tricks

• 10 Git tricks

• Demo of Git tricks with pull request

Saturday, 19 January, 13

Page 3: Ten Things You Didn't Know Git And GitHub Could Do

Ten GitHub Tricks

http://octodex.github.com/front-end-conftocat

Saturday, 19 January, 13

Page 4: Ten Things You Didn't Know Git And GitHub Could Do

t: file finder

Saturday, 19 January, 13

Page 5: Ten Things You Didn't Know Git And GitHub Could Do

w: branch filter

Saturday, 19 January, 13

Page 6: Ten Things You Didn't Know Git And GitHub Could Do

?: list of shortcuts

Saturday, 19 January, 13

Page 7: Ten Things You Didn't Know Git And GitHub Could Do

whitespace: ?w=1

Saturday, 19 January, 13

Page 8: Ten Things You Didn't Know Git And GitHub Could Do

commits by range

• github.com/user/repo/compare/{range}

• range = sha1...sha2 or master...my-branch

• time can be considered: master@{time}...master

• e.g. master@{2012-01-01}...master

Saturday, 19 January, 13

Page 9: Ten Things You Didn't Know Git And GitHub Could Do

commits by range

https://github.com/rails/rails/compare/master@{1.day.ago}...master

Saturday, 19 January, 13

Page 10: Ten Things You Didn't Know Git And GitHub Could Do

commits by author

• github.com/user/repo/commits/branch

• appending param ?author=github_handle

Saturday, 19 January, 13

Page 12: Ten Things You Didn't Know Git And GitHub Could Do

.diff & .patch

• Add .diff or .patch to the URLs of compare view, pull request or commit page

• diff or patch in text format

• e.g., easy for building tools

Saturday, 19 January, 13

Page 14: Ten Things You Didn't Know Git And GitHub Could Do

email reply

Saturday, 19 January, 13

Page 15: Ten Things You Didn't Know Git And GitHub Could Do

line linking

• any file view

• click one line or multiple lines by pressing SHIFT

• good for sharing link to a chunk of code

Saturday, 19 January, 13

Page 17: Ten Things You Didn't Know Git And GitHub Could Do

subscribing peoplesMentioning users in pull requests, issues or any comment will subscribe them to all subsequent notifications

Saturday, 19 January, 13

Page 18: Ten Things You Didn't Know Git And GitHub Could Do

autolink

• In pull requests, issues or any comment, sha and issue number will be automatically linked

• link sha or issue number from another repository with the format of user/repo@sha1 or user/repo#1

• e.g. rails/rails#1

Saturday, 19 January, 13

Page 19: Ten Things You Didn't Know Git And GitHub Could Do

autolink

Saturday, 19 January, 13

Page 20: Ten Things You Didn't Know Git And GitHub Could Do

hub

• command line GitHub

• brew install hub or gem install hub

• hub pull-request

• https://github.com/defunkt/hub

Saturday, 19 January, 13

Page 21: Ten Things You Didn't Know Git And GitHub Could Do

Demo: GitHub Tricks

• shortcuts: t, w, ?

• ignoring whitespace: https://github.com/dynjs/dynjs/commit/45ec2e9c08ad10fc28c7a6c3016ef2eab158e20e

• commits by range: https://github.com/acl-services/accounts/compare/master@{yesterday}...master

• commits by author: https://github.com/dynjs/dynjs/commits/master?author=jingweno

• line linking: https://github.com/acl-services/devise-acl/blob/master/Gemfile

Saturday, 19 January, 13

Page 22: Ten Things You Didn't Know Git And GitHub Could Do

Ten Git Tricks

Saturday, 19 January, 13

Page 23: Ten Things You Didn't Know Git And GitHub Could Do

git log -p FILE

Saturday, 19 January, 13

Page 24: Ten Things You Didn't Know Git And GitHub Could Do

git log -S'PATTERN'

Saturday, 19 January, 13

Page 25: Ten Things You Didn't Know Git And GitHub Could Do

git add -p

Saturday, 19 January, 13

Page 26: Ten Things You Didn't Know Git And GitHub Could Do

git rm --cached FILE

Saturday, 19 January, 13

Page 27: Ten Things You Didn't Know Git And GitHub Could Do

git log ..BRANCH

Saturday, 19 January, 13

Page 28: Ten Things You Didn't Know Git And GitHub Could Do

git branch --merged & git branch --no-merged

Saturday, 19 January, 13

Page 29: Ten Things You Didn't Know Git And GitHub Could Do

git branch --contains SHA

Saturday, 19 January, 13

Page 30: Ten Things You Didn't Know Git And GitHub Could Do

git status -s

Saturday, 19 January, 13

Page 31: Ten Things You Didn't Know Git And GitHub Could Do

git reflog

Saturday, 19 January, 13

Page 32: Ten Things You Didn't Know Git And GitHub Could Do

git shortlog -sn

Saturday, 19 January, 13

Page 33: Ten Things You Didn't Know Git And GitHub Could Do

Create Shortcuts!

Saturday, 19 January, 13

Page 34: Ten Things You Didn't Know Git And GitHub Could Do

Demo: Git Tricks with Pull Request

• Fix the README of devise-acl

• gem install omglog

• hub pull-request

• rebase vs. merge vs. merge --no-ff

Saturday, 19 January, 13

Page 36: Ten Things You Didn't Know Git And GitHub Could Do

Q & A

http://octodex.github.com/gangnamtocat.md

Saturday, 19 January, 13