Skip to content

Instantly share code, notes, and snippets.

@shime
Last active April 29, 2023 20:04
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save shime/4663460 to your computer and use it in GitHub Desktop.
Save shime/4663460 to your computer and use it in GitHub Desktop.
Secret Github Features

Taken from Zach Holman's "Git and Github Secrets".

Keyboard Shortcuts

t - quickly jump through files (similar to cmd+T in VI or Text Mate)

w - quickly switch branches

s - search

? - keyboard shortcuts help

HUB

Awesome command line Github wrapper (repo).

Makes Github related stuff a lot easier.

Example:

$ hub clone rtomayko/tilt

# expands to

$ git clone git://github.com/rtomayko/tilt.git

Alias it to git, it feels nicer. This is not dangerous because it just adds more sugar to your git command.

Diff and Patch

Wanna see the diff or patch of a commit or the pull request? Just add .diff or .patch to the URL.

Example:

I wanna see what has changed in rails/rails#9105.

Here's where I see it: https://github.com/rails/rails/pull/9105.patch.

Adding ?w=1 ignores white spaces. Use it in commits or anywhere else.

SVN also works

Github translates SVN calls to GIT calls. Not that you care because no one uses SVN without a weapon threat.

Gists

You can use it as a prototyping platform.

What does that mean?

Put the CSS file in a Gist. Share it with your colleagues. No one will understand it. Put it in a website and reference this CSS file in a header. Now everyone understands.

Also, praise the awesomeness of Gist.io!

You're looking at it. Isn't it awesome? Minimalistic and all, right? Use it as a blogging platform.

Here's the original gist: https://gist.github.com/4663460

Mentions

When you mention someone with @username, that user gets subscribed to the updates. You can also mention teams with @org/team. Eg. @github/designers.

If you mention a SHA in a commit message, Github autolinks to that commit. You can also mention commits in a different repos.

Use user@sha1 for a forked repo and user/repo@sha1 for a different repo.

This works with issues too. To explain, you can use any of these:

  • #1
  • USER#1
  • USER/REPO#1

You can use this to close issues. Example:

closes #1

Works with "fix" too.

Syntax highlighting

Specify your language!

Use ```ruby instead of ```. 

It makes a difference.

Commits by Author

Just add the author param to the URL.

To see all commits on play/play by @holman, you can use

http://github.com/play/play/commits/master?author=holman

Pull Request Magic

Pull requests are not available only on forks. They work with branches too, use them for better merges. Github uses this internally, they just branch out one repo for all the members of their team. No headaches with permissions.

Use Screenshots

Embed images inside pull requests!

Syntax:

![title](http://example.com/image.png)

Praise the awesomeness: rails/rails#9001

Emoji is cool

Why use words when you can use Emoji?

:heart: :+1: :-1: :rage2: :poop:

Here's the cheat sheet:

http://www.emoji-cheat-sheet.com/

Line Linking

Use it to highlight code. Just add #L55 to the file URL if you wish to highlight the line 55 of some file.

Works with ranges too. Proof:

https://github.com/rails/rails/blob/master/activerecord/lib/active_record/core.rb#L82-93

Comparing Branches

Check it out, it's awesome. This is the format needed:

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

{range} is usually something like MASTER...MY-BRANCH

Add the cool git features to this and it becomes black magic. To see what has changed in the last 24 hours, for instance, you can use this:

github.com/user/repo/compare/master@{1.day.ago}...master

master@{yesterday} and master@{2012-02-25} also works.

@Explosion-Scratch
Copy link

Wow! Thank you! I will certainly use some of these! :)

@privefl
Copy link

privefl commented Oct 3, 2020

@shime
Copy link
Author

shime commented Oct 3, 2020

@privefl I have no idea why that doesn't work.

@whippingdot
Copy link

If you can, can you add more secrets. One of them I know is that if you create a repo with your name as the name of the repo, the README file in that repo shows up in your profile page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment