| 12345678910111213141516171819202122232425262728293031323334353637 |
- <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><meta name="author" content="mitm"><title>Github Tips</title><link rel="stylesheet" href="./asciidoctor.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"><link rel="stylesheet" href="/home/travis/build/jMonkeyEngine/wiki/build/asciidoc/html5/twemoji-awesome.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/github_tips.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"></div><h1>Github Tips</h1><div class="details"><span class="author" id="author">mitm</span><br><span id="revnumber">version ,</span> <span id="revdate">2019-09-08T23:24:11.262Z</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#inserting-code-links-into-forum-posts">Inserting code links into forum posts</a></li><li><a href="#creating-permanent-links">Creating permanent links</a></li><li><a href="#canonical-urls">Canonical URLs</a></li></ul></div></div><div id="content"><div class="sect1"><h2 id="inserting-code-links-into-forum-posts">Inserting code links into forum posts</h2><div class="sectionbody"><div class="paragraph"><p>There will come a time when you may wish to insert links from github into your forum posts to highlight problems in code, clarify some point your making, or provide more background. Whatever the reasons, here are a few pointers that will help make your posts more robust.</p></div></div></div>
- <div class="sect1"><h2 id="creating-permanent-links">Creating permanent links</h2><div class="sectionbody"><div class="paragraph"><p>To create a link to a specific line in a file located on github all you need to do is click the line number inside the file. A three dot tag will appear and the line will be highlighted in yellow.</p></div>
- <div style="text-align: left;" class="imageblock"><div class="content"><img src="wiki/github_tag.png" alt="github_tag.png"></div></div>
- <div class="paragraph"><p>This will append the line number to the URL in your address bar with the format <code>#L<number></code>, in our case <code>#L61</code>.</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code>https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java#L61</code></pre></div></div>
- <div class="paragraph"><p>Click the three dot tag and a option menu will appear.</p></div>
- <div style="text-align: left;" class="imageblock"><div class="content"><img src="wiki/github_tag_menue.png" alt="github_tag_menue.png"></div></div>
- <div class="paragraph"><p>Select the <code>Copy permalink</code> option and now you can paste the URL into any forum post or wiki issue and the code display window will show your selection like so:</p></div>
- <div class="paragraph"><div class="title">jMonkey forum</div>
- <p><span class="image"><img src="wiki/github_jme_forum.png" alt="github_jme_forum.png"></span></p></div>
- <div class="paragraph"><p>The same thing applies to github.</p></div>
- <div class="paragraph"><div class="title">Github issue</div>
- <p><span class="image"><img src="wiki/github_issue_write.png" alt="github_issue_write.png"></span></p></div>
- <div style="text-align: left;" class="imageblock"><div class="content"><img src="wiki/github_issue_preview.png" alt="github_issue_preview.png"></div></div>
- <div class="paragraph"><p>If you want to select more than one line:</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p>Select the start line number.</p></li><li><p>Hold down the <kbd>Shift</kbd> key.</p></li><li><p>Select the ending line number.</p></li></ol></div>
- <div style="text-align: left;" class="imageblock"><div class="content"><img src="wiki/github_multiline.png" alt="github_multiline.png"></div></div>
- <div class="paragraph"><p>All the lines between will be highlighted as well. This will change the URL using the format <code>#L<number>-L<number></code>, in our case <code>#L83-L86</code>.</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code>https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java#L83-L86</code></pre></div></div>
- <div class="paragraph"><p>The above mentioned links are just normal URLs. This means that this line will be linked forever at this point in this file as long as it exists. What if the line changes or what you were referring to goes away or moves to another line? Canonical URLs to the rescue!</p></div></div></div>
- <div class="sect1"><h2 id="canonical-urls">Canonical URLs</h2><div class="sectionbody"><div class="paragraph"><p>A Canonical URL will attach the SHA hash number of the commit to the URL so even if the file changes, that link will always point to the same file and same line.</p></div>
- <div class="listingblock"><div class="title">Normal URL</div>
- <div class="content"><pre class="CodeRay highlight"><code>https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java#L83-L86</code></pre></div></div>
- <div class="listingblock"><div class="title">Canonical URL</div>
- <div class="content"><pre class="CodeRay highlight"><code>https://github.com/jMonkeyEngine/jmonkeyengine/blob/a9afcecc41b54feaac253e38d2f2282c8c6027fc/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java#L83-L86</code></pre></div></div>
- <div class="paragraph"><p>Notice the hash commit number is now part of the URL.</p></div>
- <div class="paragraph"><p>To make the Canonical URL just select the <kbd>y</kbd> hot key after selecting the line number or numbers. Once you have done this, all links from thereafter will be Canonical URLs.</p></div>
- <hr>
- <div class="paragraph"><p>Suggested reading:</p></div>
- <div class="ulist"><ul><li><p><a href="https://help.github.com/en/articles/keyboard-shortcuts#source-code-editing">Source code browsing</a></p></li><li><p><a href="https://help.github.com/en/articles/getting-permanent-links-to-files">Getting permanent links to files</a></p></li></ul></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2019-12-20 22:31:09 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
- apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
- indexName: 'jmonkeyengine',
- inputSelector: '#doc-search',
- debug: false // Set debug to true if you want to inspect the dropdown
- });</script></body></html>
|