Tag: files

How to upload your speaker slides to your GitHub repo – 058

If you give talks or want to upload extra documentation or slides to your repos, you have a couple of options!

1. Push your PowerPoint slides to your repo to retain a copy

First, you can simply upload your slides, e.g. .ppt or .pptx, to your repo.

ppt file in a repo

You won’t be able to see the slides when you click on the PowerPoint filename, but anyone who clicks on View Raw will download the deck.

powerpoint deck uploaded to GitHub

2. Push a PDF of your slides to your repo for others to view without downloading

Next If you save your PowerPoint slides as a PDF and push those to GitHub,

pdf file in a repo

GitHub will render your PDF files as subsequent images.

PDF slides shown as subsequent images

Note re diff’ing

Unfortunately, because these are binary files, you won’t be able to see any rich diff information for the commit.

Binary file not shown for powerpoint or pdf commit diff

How to write your repo README in a markup language other than markdown – 057

Markdown not your thing? GitHub supports more than just markdown for your Readme markup language. You can view the full list of supported markup languages.

For example, the following readme is written in Creole instead of markdown.

repo README written in Creole

The code used to render readmes on GitHub is an open source project called Markup which is accepting contributions.

Now if you’re like me and love to break software by trying different combinations of things, you might ask, “What happens if I add both a README.md and a README.creole or other markup language file?” It looks like the first readme file that got created wins (i.e. the readme that is displayed). If you delete the readme file being shown (e.g. README.creole as shown in my example) and you’ve already added a README.md file, the README.md file’s contents will be displayed.

How to render a CSV and TSV file as an interactive table on GitHub – 056

If you have a csv or tsv file in your repo, GitHub will automatically display it as a table that you can search and filter on.

csv file displayed as table

Similar to source code, you can click a row (or shift+click multiple rows) to highlight, and copy that URL to send to someone, e.g. https://github.com/saraford-tips/fluffy-octo-robot/blob/master/inventory.csv#L6-L8

Multiple rows highlighted

You can also search within the spreadsheet. Although I couldn’t find a keyboard shortcut, as ‘s’ goes to the overall search this repo search box.

Search within table

How to press ‘y’ to navigate to the permalink for a file’s exact commit ID on GitHub.com – 052

Suppose you had a question about the contents of a file at an exact moment in time (or in git-speak: at an exact commit in time). If you were to visit the repo and navigate directly either to a file or the line in question in a file, e.g. https://github.com/saraford/your-moment-of-github-zen/blob/master/main.js#L74 showing the line

mainWindow.webContents.openDevTools();

you might forget or not even realize (like me) that you’re copying the link for the latest version of that file on master (or in git-speak: the version of the file at the current head of master).

In other words, if someone were to come along and make a change to this file, your link to this line of code at the latest commit on master might be a link to a totally different line of code instead of the openDevTools() link.

Press the `y` key and you’ll see that the page seems to refresh. Well, yes and no. The page has updated, but look at the URL now.

https://github.com/saraford/your-moment-of-github-zen/blob/f06f035cfed7c0ea05db8bd3cc25b22c43cea6d7/main.js#L74

now you got the permalink to that exact line of code!

This shortcut is the functional equivalent of clicking Code – Commit – Browse the repository at this point in the history – clicking the file (e.g. main.js) – and then clicking the line number.

This shortcut works for any branch name, specific commit SHAs, and tags, according to the docs. E.g. suppose you were looking at main.js on a branch called windows-fix located at https://github.com/saraford-tips/your-moment-of-github-zen/blob/windows-fix/main.js and you pressed the `y` key. The URL would change to https://github.com/saraford-tips/your-moment-of-github-zen/blob/811aacbd492044c8a02536129edf42862d0a593d/main.js

I hate not having a photo to go alongside a tip, so here’s a picture of a Great Dane next to a small (terrier?) dog, aka how I feel standing next to tall people.

Great Dane standing next to small dog

photo taken from https://flic.kr/p/b4RGX8

How to link directly to a line of code in a file hosted on GitHub – 043

It’s a lot easier to point someone directly to a line of code you’re referring to, rather than sending them the link to a file with a message “and now scroll to line 74.”

First, you’ll navigate to a file hosted on GitHub. It could be a file you’ve checked in or any random file in any random repo.

Next, click on the line number that you want to get a link to. In today’s example, you’ll see me refer to one of my sample Electron apps where I forgot to remove the line that shows developer tools for debugging.

Clicking line number in a file on GitHub.com

And volia, check your web browser address bar. You now have a URL for that exact line of code, e.g.  https://github.com/saraford/your-moment-of-github-zen/blob/master/main.js#L74

When you send this link to someone else, the line of code will open around the middle of the screen with the yellow highlight.

How to turn on word wrap when editing a file on GitHub.com – 036

If you like to write, you’ll often run into the text not auto-wrapping, especially on markdown documentation files.

Whenever you run into a case where the line isn’t wrapping, just look up and you’ll see the option to change the Line wrap mode from No wrap to Soft wrap.

No wrap line wrap mode button

Changing to Soft warp now shows the line wrapped.

Soft wrap showing where the line has been wrapped

I had to look up the difference between soft wrap and hard wrap, since I thought “why not just name it No wrap vs Wrap?” But I guess they wanted to be explicit in saying that this option wasn’t going to insert actual line breaks.

How to view the latest commit made within a particular folder on GitHub – 030

Something I had a hard time grasping early on using GitHub was why the latest commit would keep change. Obviously, at the root level (homepage level), the Latest commit is showing the latest commit for the entire repo, but why does it keep changing after that?

The latest commit is showing you the commit for the last time any files at this folder level were modified. Let’s look at my simple random-example.

When you go to the main repo page, you’ll see the Latest commit c8cac61 3 days ago (at the time of this writing) is the last commit to the repo.

main repo page - Latest commit c8cac61 3 days ago

But then if you click inside the Randomness folder, you’ll see the latest commit changes to Latest commit 567c29d 6 days ago.

Randomness folder showing commit 567c29d 6 days ago

And if you continue to drill down into these folders, you’ll see that the latest commit continues to change to c59c490 6 days ago.

Latest commit c59c490 6 days ago

What is with all these changes?

The latest commit is showing you the commit for the last time any files at this folder level were modified.

Again, I’m a visual learner (as you’ve noticed by now), so here’s an example. In the image below, you are looking at the C# Project folder called Randomness with Latest commit 567c29d 6 days ago. Notice how there are multiple files.

Randomness folder showing Latest commit 567c29d 6 days ago

Clicking the Latest commit 567c29d 6 days ago shows the actual file(s) that were modified as part of that commit, which in this case was just one file.

commit 567c29d showing only 1 file Class1.cs modified