GeekOut Estonia 2013
Level Up Your Git and GitHub Experience
GitHub is home to over three million people who use it as the definitive place to collaborate around code. What started five years ago as
simple Git hosting is now a toolbox of collaborative features that continues to grow with new-emerging features and usages. Join Brent
Beer and Jordan McCullough as they explore tips, techniques, and GitHub workflows that will help you level up your collaborative coding
skills
Maximizing Use of GitHub
Link to issues by number as text
Mention in commit with #<issue number>
Issue auto-updated with commit reference
Pull Requests are issues
External repo issue referencing
<username>/<repo>#<number>
Issues with Commit Integration
Commit message auto close when issue mentions included
<fixes|fixed|fix> #xxx
<resolve| resolves | resolved> #xxx
<closes|close|closed> #xxx
Issues reference a Commit
Commit hash linking in issues (automatic)
Mentions in Pull Requests, Issues
@ mention account handles
Support for users and teams
Line-by-line commenting
Auto-linking in issues
Branches update automatically
GitHub-Flavor-Markdown and Task Lists
Support with - [ ] markdown
Modify and update with a click
GitHub URL Tricks
Ranges <repo-url>/compare/<ref>...<ref>
<branch>@{1.day.ago}
Commiters / Authors
<url>?author=<name>
<url>?commiter=<name>
Understanding GitHub Branch Metrics
Same as command line git branch -vv
Shows what is behind/ahead from parent and commit relationship
Resolving Auto-Merge Conflicts
GitHub.com PR cannot be completed
Resolve on command line
git ls-remote
Retrieving from same repo
Using FETCH_HEAD
Branching from
Merging from
Resolving with
Reverse Merge
Assess first with git fetch
Forks
Keeping up to date
Adding a secondary remote
Fetching (read), merging (local), pushing (write)
RefSpec & Airplane Mode
Pattern <src>:<dstn>
What’s the +
Limited what is fetched
Traditional fetch retrieves only refs/heads
Retrieve Pull Requests with git ls-remote
Retrieving with Fetch
git config remote.<name>.fetch <src:dst>
+refs/heads/*:refs/remotes/origin/*
+refs/heads/master:refs/remotes/origin/master
+refs/heads/qa/*:refs/remotes/origin/qa/*
git config --add remote.<name>.fetch <refspec>
+refs/pull/*/head:refs/remotes/origin/pull/*
Controlling Pushes
git config remote.<remote>.push <refspec>
refs/heads/master:refs/heads/qa/master
refs/heads/qa/master:refs/heads/qa/master
Gists (quick one-branch repos)
Commit on GitHub
Clone down locally
Fork, edit, share, star
pushing to multiple gists with multiple remotes. ex) git push oscon oscon:master
Cherry-Pick
git cherry-pick <ref>
git cherry -v <ref>
Verifying picks before discarding a branch
IRL Examples
Retrieving good work from prototype branches
Integrating selected commits from a Pull Request
Then use commit message fixes #<val> to auto close PR
Rebase Interactive
General use
git rebase -i <ref|ref-range>
Anticipating many commits with autosquash
git commit -i --autosquash
Configure as default on any rebase
git config rebase.autosquash
Rebase - Configurations & Shortcuts
Apply local commits on top of fetch merge
git pull --rebase <origin> <branch>
Configuration for branch rebase default on push with -u
git config branch.autosetuprebase always|never|local|remote
Specific branch rebasing behavior configuration
git config branch.<name>.rebase true
Searching, Blaming, & Responsibility
By patch content
git log -S "<content-string>"
By regex on commit message
git log --grep=<regex>
By author name or time
git log --committer=<name>
git log --since=7.months.ago
By Filter
git log --diff-filter=<A|D|M>
By File
Last commit affecting each line changed
git blame <filepath>
git blame -L<start-line>,<end-line>
Cleaning Remotes
Remove non-matching local remote branches
git remote update --prune
Remove non-matching remote upstream branches
git push <remote> --prune
Remove only remote upstream branch
git push origin :<branch-name>

Level Up Your Git and GitHub Experience by Jordan McCullough and Brent Beer

  • 1.
    GeekOut Estonia 2013 LevelUp Your Git and GitHub Experience GitHub is home to over three million people who use it as the definitive place to collaborate around code. What started five years ago as simple Git hosting is now a toolbox of collaborative features that continues to grow with new-emerging features and usages. Join Brent Beer and Jordan McCullough as they explore tips, techniques, and GitHub workflows that will help you level up your collaborative coding skills Maximizing Use of GitHub Link to issues by number as text Mention in commit with #<issue number> Issue auto-updated with commit reference Pull Requests are issues External repo issue referencing <username>/<repo>#<number> Issues with Commit Integration Commit message auto close when issue mentions included <fixes|fixed|fix> #xxx <resolve| resolves | resolved> #xxx <closes|close|closed> #xxx Issues reference a Commit Commit hash linking in issues (automatic) Mentions in Pull Requests, Issues @ mention account handles Support for users and teams Line-by-line commenting Auto-linking in issues Branches update automatically GitHub-Flavor-Markdown and Task Lists Support with - [ ] markdown Modify and update with a click GitHub URL Tricks Ranges <repo-url>/compare/<ref>...<ref> <branch>@{1.day.ago} Commiters / Authors <url>?author=<name> <url>?commiter=<name> Understanding GitHub Branch Metrics
  • 2.
    Same as commandline git branch -vv Shows what is behind/ahead from parent and commit relationship Resolving Auto-Merge Conflicts GitHub.com PR cannot be completed Resolve on command line git ls-remote Retrieving from same repo Using FETCH_HEAD Branching from Merging from Resolving with Reverse Merge Assess first with git fetch Forks Keeping up to date Adding a secondary remote Fetching (read), merging (local), pushing (write) RefSpec & Airplane Mode Pattern <src>:<dstn> What’s the + Limited what is fetched Traditional fetch retrieves only refs/heads Retrieve Pull Requests with git ls-remote Retrieving with Fetch git config remote.<name>.fetch <src:dst> +refs/heads/*:refs/remotes/origin/* +refs/heads/master:refs/remotes/origin/master +refs/heads/qa/*:refs/remotes/origin/qa/* git config --add remote.<name>.fetch <refspec> +refs/pull/*/head:refs/remotes/origin/pull/* Controlling Pushes git config remote.<remote>.push <refspec> refs/heads/master:refs/heads/qa/master refs/heads/qa/master:refs/heads/qa/master Gists (quick one-branch repos) Commit on GitHub Clone down locally Fork, edit, share, star pushing to multiple gists with multiple remotes. ex) git push oscon oscon:master Cherry-Pick git cherry-pick <ref> git cherry -v <ref>
  • 3.
    Verifying picks beforediscarding a branch IRL Examples Retrieving good work from prototype branches Integrating selected commits from a Pull Request Then use commit message fixes #<val> to auto close PR Rebase Interactive General use git rebase -i <ref|ref-range> Anticipating many commits with autosquash git commit -i --autosquash Configure as default on any rebase git config rebase.autosquash Rebase - Configurations & Shortcuts Apply local commits on top of fetch merge git pull --rebase <origin> <branch> Configuration for branch rebase default on push with -u git config branch.autosetuprebase always|never|local|remote Specific branch rebasing behavior configuration git config branch.<name>.rebase true Searching, Blaming, & Responsibility By patch content git log -S "<content-string>" By regex on commit message git log --grep=<regex> By author name or time git log --committer=<name> git log --since=7.months.ago By Filter git log --diff-filter=<A|D|M> By File Last commit affecting each line changed git blame <filepath> git blame -L<start-line>,<end-line> Cleaning Remotes Remove non-matching local remote branches git remote update --prune Remove non-matching remote upstream branches git push <remote> --prune Remove only remote upstream branch git push origin :<branch-name>