Talks

Summarized using AI

Git and GitHub Secrets

Zach Holman • October 08, 2012 • Earth

In this talk titled "Git and GitHub Secrets" presented by Zach Holman at Aloha RubyConf 2012, the speaker shares various features and tricks of Git and GitHub that are not commonly known or accessible through the user interface. Holman emphasizes that both Git and GitHub have a plethora of hidden capabilities that can enhance the user experience and improve workflow efficiency.

Key points discussed include:

  • Hidden Features: GitHub has many features that users may not be aware of, often referred to as 'secrets' due to their absence in the UI. These include additional diff tools and email hacks.
  • Working with Diffs: Users can suffix URLs with 'diff' or 'patch' to receive text-only outputs of changes in commits. Special flags like 'w=1' can help ignore whitespace issues in diffs.
  • Subversion Integration: Holman explains that GitHub supports Subversion, allowing users to interact with Git repositories through Subversion commands seamlessly.
  • Clone Protocols: The shift from SSH to HTTP for cloning repositories is discussed, focusing on usability and accessibility, especially for those unfamiliar with SSH key management.
  • Credential Management: Users are encouraged to utilize Git's credential caching to streamline authentication processes.
  • Gist Feature: Gists are highlighted as versatile tools for sharing code snippets and can function as complete repositories.
  • Visual Diffs and Security Audits: GitHub provides features for visualizing changes in images and auditing security settings within account preferences.
  • Command Line Enhancements: Holman introduces Hub, a command-line tool that extends Git's functionality and streamlines interactions with GitHub.
  • Shortcuts and Auto-linking: Keyboard shortcuts enhance navigation within GitHub repositories, and auto-linking features simplify referencing commits and issues in discussions.
  • Branch Comparisons and Multiple Remotes: Tips on comparing branches and managing multiple remotes are shared, along with practical commands for efficient history tracking and staging in Git.

Holman's presentation concludes with encouragement for users to explore these features and incorporate them into their workflows to enhance productivity and capability in using Git and GitHub. The session wraps up with a Q&A segment allowing the audience to ask questions regarding the material discussed.

Git and GitHub Secrets
Zach Holman • October 08, 2012 • Earth

We tuck a lot of features away on github.com.

Sometimes the UI just hasn't been fleshed out. Or we have bigger plans in mind for the feature in the future. Or it just hasn't been finished yet. But we still want to give you the flexibility of using that feature today.

The same can be said about Git. If you've ever looked at the manpages, there's feature after feature and option after option in its binaries. Part of the strength of Git and GitHub is having access to those features when you need them, and getting them out of your way when you don't.

This talk covers both Git and GitHub: different tricks I've picked up after two years at GitHub, helpful advice on common gripes I've seen in support tickets and tweets, and just general nifty things that make you a faster, more capable technologist.

Help us caption & translate this video!

http://amara.org/v/FGgS/

Aloha RubyConf 2012

00:00:15.679 All right, we're going to talk about Git and GitHub today. I'm Zach Holman, you can find me as Holman on Twitter and GitHub. I work for GitHub Incorporated, where we host source code. If you don't know what GitHub is, this talk may be a bit confusing for you. First, I want to let you know that I'm not a smart guy; I'm really not that bright. However, I hang around lots of smart people, and by just interacting with them in chat rooms, I've learned a whole bunch of valuable information.
00:00:39.320 Unfortunately, most of what I learn comes from our internal discussions and support tickets. I've become really good at things like tacos and eating, but we also talk about Git a lot. I like to read the tweets you send to GitHub, support requests, blog discussions, and from reading all this stuff, I've learned a lot about Git, GitHub, and the problems that people face.
00:01:02.359 Today, I'm going to cover a lot of material quickly. My goal is to share a whole bunch of tricks I've picked up over the past two years at GitHub. Sometimes, my talks are much more high-level and philosophical, but not this time. You can take notes if you want, and I'll put these slides online afterward. So, if you want to track down some weird, arcane Git command later, you can revisit the slides.
00:01:29.280 First, let’s discuss what I mean by 'secrets'. Basically, everything can be considered a secret because the UI of GitHub can be overwhelming. At GitHub, we have features that don’t always make it into the UI. For this talk, I’ll refer to those features as secrets. We have hidden HTML diff tools, email hacks, and many other capabilities we don't typically announce or add buttons for. The reason behind this limitation is we want to experiment with different functionalities.
00:02:05.320 By the end of this talk, you might wonder why we don’t just add buttons for those features on the UI. So, I decided to mockup what GitHub would look like if we did add all those features—minus a few silly aspects, of course. Our aim is to keep things simple while being flexible enough for power users to do cool things, which is what I’ll be talking about.
00:02:42.720 This talk will have two parts: one focused on GitHub, and the other on Git. So, let's dive right into it.
00:03:08.480 First, let’s discuss quick diff and patch. If you add 'diff' or 'patch' to any diff URL online, you'll receive a text-only output of that command through Git. Whether you are dealing with command-line tasks to script quick summaries of what changes occurred in commits, you can get the diff output by simply adding those commands to any URL. This works not just on diff pages but also on compare views, pull requests, and commit pages. Anytime there’s a diff, GitHub provides a textual representation you can access.
00:03:49.640 Additionally, if you work with team members who are not careful with whitespace—those who, for example, unknowingly commit trailing whitespace—you can add 'w=1' to the URL to truncate all the extraneous whitespace. This way, you get to see the actual changes instead of having the diff cluttered with 40 lines of untouched whitespace.
00:04:06.799 Next, let's discuss subversion. I personally prefer Git, but it's worth noting that GitHub is the largest Subversion host online as well. Every single Git repository on GitHub is also a Subversion repository. We achieve this via a special SVN git service layer on our end.
00:04:30.120 When you send a Subversion call to GitHub, we translate those calls into Git commands on our servers and act accordingly. Almost all Subversion commands are supported, which is great for those who may prefer Subversion for their workflow.
00:05:02.520 Let’s talk a little bit about HTTP and SSH. A few months ago, we stealthily changed the default protocol for cloning repositories from SSH to HTTP. You may ask why we made this decision. The primary reason is related to usability; 'Smart HTTP' is now the protocol of choice, offering efficient server-side pack file generation, allowing quicker responses. This change also benefits users in corporate environments where firewalls can block SSH.
00:05:46.039 Many users find key generation difficult, especially those on Windows or for non-technical users. We made this shift because many people don't know how to setup SSH keys. Most of you may say this isn't relevant, but one common issue arises when you accidentally clone an HTTP URL but wanted SSH. This leads to repeated username and password prompts on GitHub, which is frustrating for users.
00:06:18.840 To help with this, Git introduced credential caching in Git version 1.7.9. Here’s a URL where you can set it up according to your distribution. For Mac users, the latest Homebrew installs credential caching by default, which securely stores all your credentials in the keychain, allowing for a stress-free experience without repeated password prompts. But if you still prefer SSH, you can simply click that option, and we will remember it for the future.
00:06:55.760 Next, cloning without the actual Git. You can clone a URL without typing the whole thing out. Many people have also discovered GitHub's new icon sets and how they look on Retina displays. If you press Command + Plus on macOS or pinch to zoom on iOS, the page will scale up nicely with crisp icons, which is a major advantage for those who appreciate pixel-perfect graphics.
00:07:29.960 Also interesting is the ability to audit security features in your GitHub account settings. If you’re paranoid about security—and rightly so—you can find a lesser-known security tab in your settings that shows you public keys created or modified on your account, as well as deleted repositories. This can help trace unauthorized changes to your account.
00:08:04.960 Now, let's briefly discuss the Octocat mascot. The origins of the Octocat story are amusing because we originally implemented it using cheap stock art, an iStock photo. We wanted something cute for our pages to mitigate negativity, and the story evolved as the community began to embrace the Octocat, leading to the rights acquisition and turning it into a beloved mascot. For fun, we accumulated many octopus animations and clip art at octodex.com.
00:09:03.000 Next, let's talk about Gist, which acts as our code snippet repository. Gist is often underrated, being perceived just as a code snippet tool, but it has other fun uses. If I need to share cool designs or CSS snippets, it's ideal. For instance, one of our designers shared CSS ideas within a Gist, allowing for easy collaboration and prototyping of ideas without requiring a full repository.
00:09:50.560 Additionally, Gists are full repositories. You can clone them and even create Micro Gems by including a gem spec file in your Gist. This makes it seamless to use Bundler for dependency management without the overhead of a complete project.
00:10:59.440 We also have various image view modes for visual diffs. If you upload a new version of an image, GitHub can demonstrate the changes between image versions. Designers often make subtle changes to pixels, so being able to visually identify what changed helps clarify differences quickly.
00:11:51.279 Let’s talk about Hub for a moment. It's a command-line wrapper around Git that adds additional functionality for GitHub. You can install it via Homebrew or with a one-liner. Hub allows you to use commands like 'hub clone' to quickly clone repositories without typing the full URL. It also supports multi-remote pushes, which is beneficial for more complex workflows.
00:12:40.240 Another useful feature of Hub is the ability to attach pull requests to issues directly from the command line. Many users may start with an issue and then later want to create a pull request based on it. With Hub, you can create that pull request directly using a simple command.
00:13:10.160 On GitHub, there is a fun Easter egg: if you press T on a repository page, you can access a quick file finder. This is a powerful feature that allows you to type out a file anywhere in your repository to jump to it quickly. Similarly, pressing W will bring up the branch selector if you want to switch between branches quickly. S allows for searching, and the Question Mark provides a list of all available keyboard shortcuts.
00:14:15.680 At GitHub, we often subscribe team members to relevant issues without disturbing them directly. If you encounter an issue wanting someone's attention, simply CC them to ensure they get notifications about that conversation. For organizations, you can also subscription teams by addressing the post to 'Org' followed by team names.
00:14:50.639 Another benefit is auto-linking Shas in the comments. When you mention a SHA, GitHub automatically converts that portion into a hyperlink, allowing for quick navigation to relevant commits. Similarly, you can auto-link issues with a simple pound sign followed by the issue number, creating an intuitive link directly to that issue.
00:15:49.120 Syntax highlighting is also a key component in making README files more readable. By specifying the language using triple backticks, you can achieve syntax highlighting in your documentation. You can also use keywords like 'closes' or 'fixes' in your commit messages to automatically close issues that are mentioned within those messages.
00:16:33.480 If you browse a project’s commit history, you can filter contributions by authorship. To do this, you can append a query parameter author= to a particular repository’s commits URL. This functionality is ideal for showcasing your contributions in a project, especially during resume reviews.
00:17:07.360 Pull requests in GitHub work best as branch-to-branch interactions. It's common within organizations to leverage pull requests for collaboration using the same repository. This type of interaction removes complications associated with managing remotes for forks, streamlining the contribution process.
00:17:43.185 Moreover, when working on pull requests, you can embed screenshots using standard markdown syntax. Curating visuals to demonstrate changes is advantageous when explaining the modifications made. GitHub caches images so that if your hosting service goes down, the images remain accessible.
00:18:34.040 Hub provides convenient API access. For example, you can hit a POST request to transfer issues into pull requests directly. Emojis are also sanctioned to personalize communication; by typing a colon, you can bring up emoji options, which can make discussions more engaging.
00:19:04.480 Sometimes, you'd want to highlight specific lines during discussions. You can click on a line to highlight it in the URL, allowing you to share and refer someone to a particular note or change easily.
00:19:40.000 The comparison view of branches is a powerful feature in GitHub. You can easily compare branches by using a URL containing the range of commits between them. With this feature, users can quickly identify what was different between various development stages.
00:20:03.920 Let's transition now to Git itself, which can be more bewildering. One fun fact is that you can perform 'empty' commits using a command that allows for commit messages without any changes.
00:20:43.360 Staging chunks of changes is very effective. Using the -p flag with git add allows you to selectively stage portions of a file, promoting clarity in your commit history.
00:21:09.799 Git's way of displaying logs allows you to run specific queries. For example, if you've recently performed a silly mistake, you can use particular queries to find out where that commit happened within the project history.
00:22:00.479 Another command worth noting is git checkout - which enables you to return to previous directories on the command line. Similarly, you can switch back to the most recent branch you were on with git checkout -.
00:22:31.239 We've also implemented better service to show which branches have been merged, delineating those that haven't yet been combined into the current branch, helping developers prevent confusion.
00:23:09.600 Monitoring the blobs within branches is simplified using Git. This allows you to identify files that might have been deleted or changed without your immediate notice.
00:23:49.920 We pride ourselves on being conscientious about diff stats—showing less code is desirable. The git diff command allows users to visualize the changes made between commits efficiently.
00:24:20.360 In the Git blame command, not only can you see which line was changed but also by whom. Enhancements can be implemented to filter out whitespace alterations when conducting historical checks—a simple task that often yields significant insights.
00:24:56.799 Moreover, Git has improved features for understanding the evolution of code as it was modified or relocated through various branches. Using Git's commands will provide all necessary feedback on how the code has changed and developed over time.
00:25:31.440 The multi-remote fetch feature is useful when managing multiple repositories. It saves the hassle of fetching data from different remotes individually by collating them into one command.
00:26:09.600 Using Git status effectively can enhance your monitoring of the repository's current state, while you can alias standard commands to provide visual clarity in your interactions with Git. For example, you can create an alias that employs color for better visibility.
00:27:08.760 Also, leveraging word-diffing can help in deciphering changes in written content more effectively. This can assist not only in code manageability but also in personal writing projects, maximizing clarity.
00:28:01.840 If you come across typos or spelling mistakes in command line inputs, crafty configurations exist to account for misspellings and automatically correct the command as intended.
00:29:00.040 Additionally, you should be aware of the reuse recorded resolution feature, which remembers how to resolve previous merge conflicts, saving you the trouble of strategizing around recurring problems.
00:29:55.920 Making use of color helps to discern outputs quickly. Lastly, the git commit --amend command is a handy tool for altering commits that haven't been pushed yet, allowing you to replace the existing commit message effortlessly.
00:30:51.440 In total, I've shared various tips to enhance your Git and GitHub experiences, promoting efficiency and awareness while navigating through your development tasks.
00:31:38.080 Now it's time for questions! If anyone has any inquiries, feel free to ask.
00:32:08.400 [Voices during the question session...]
00:32:27.920 [Applause and concluding remarks]
00:32:48.000 [Music fades out]
00:39:29.799 Thank you!
Explore all talks recorded at Aloha RubyConf 2012
+17