Ten Things You Didn't Know Git And GitHub Could Do
-
Upload
owen-ou -
Category
Technology
-
view
1.218 -
download
1
Transcript of Ten Things You Didn't Know Git And GitHub Could Do
Ten Things You Didn't Know Git And GitHub
Could DoOwen Ou
@JingwenOwenOuhttp://owenou.com/2012/01/13/ten-things-you-didnt-
know-git-and-github-could-do.html
Saturday, 19 January, 13
Agenda
• 10 GitHub tricks
• Demo of GitHub tricks
• 10 Git tricks
• Demo of Git tricks with pull request
Saturday, 19 January, 13
Ten GitHub Tricks
http://octodex.github.com/front-end-conftocat
Saturday, 19 January, 13
t: file finder
Saturday, 19 January, 13
w: branch filter
Saturday, 19 January, 13
?: list of shortcuts
Saturday, 19 January, 13
whitespace: ?w=1
Saturday, 19 January, 13
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
commits by range
https://github.com/rails/rails/compare/master@{1.day.ago}...master
Saturday, 19 January, 13
commits by author
• github.com/user/repo/commits/branch
• appending param ?author=github_handle
Saturday, 19 January, 13
commits by author
https://github.com/dynjs/dynjs/commits/master?author=jingweno
Saturday, 19 January, 13
.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
.diff & .patch
https://github.com/rails/rails/compare/master@{1.day.ago}...master.patch
Saturday, 19 January, 13
email reply
Saturday, 19 January, 13
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
line linking
https://github.com/jingweno/dotfiles/blob/master/.gitconfig#L5-L9
Saturday, 19 January, 13
subscribing peoplesMentioning users in pull requests, issues or any comment will subscribe them to all subsequent notifications
Saturday, 19 January, 13
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
autolink
Saturday, 19 January, 13
hub
• command line GitHub
• brew install hub or gem install hub
• hub pull-request
• https://github.com/defunkt/hub
Saturday, 19 January, 13
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
Ten Git Tricks
Saturday, 19 January, 13
git log -p FILE
Saturday, 19 January, 13
git log -S'PATTERN'
Saturday, 19 January, 13
git add -p
Saturday, 19 January, 13
git rm --cached FILE
Saturday, 19 January, 13
git log ..BRANCH
Saturday, 19 January, 13
git branch --merged & git branch --no-merged
Saturday, 19 January, 13
git branch --contains SHA
Saturday, 19 January, 13
git status -s
Saturday, 19 January, 13
git reflog
Saturday, 19 January, 13
git shortlog -sn
Saturday, 19 January, 13
Create Shortcuts!
Saturday, 19 January, 13
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
References
• http://owenou.com/2012/01/13/ten-things-you-didnt-know-git-and-github-could-do.html
• ProGit: http://git-scm.com/book
• Advanced Git serials by Peepcode: https://peepcode.com/products/advanced-git
• Git and GitHub Secrets talk by Zach Holman: http://zachholman.com/talk/git-github-secrets
• GitFlow: http://nvie.com/posts/a-successful-git-branching-model
Saturday, 19 January, 13
Q & A
http://octodex.github.com/gangnamtocat.md
Saturday, 19 January, 13