GitHub Markdown - Add current branch name - github

Just a short question:
Is it possible to show the current branch name in e.g. README.md automatically with a placeholder or something like that using GitHub Flavored Markdown?

No, I'm not aware of anything like that within READMEs or any other markdown documents when browsing through the source of your project. And nothing turns up when searching their help page either.
However, GitHub Pages offers all sorts of info about the repo the document is associated with. Of course, GitHub Pages is a very different thing than a README file, so that may or may not be helpful to you.

Related

How can I rename a Page/Topic on GitHub wiki without renaming the file?

I want to update Topic/page titles on my GitHub wiki (which is currently using Markdown syntax). When I do that using the GUI it renames the Markdown files, and breaks all of the links.
I know that I can rename the Topic files in the Git repository and push the changes, but that doesn't help the broken links.
Is there a way to avoid this, and make GitHub Wiki's behave more like other Wiki products? I could not find an better way on GitHub documentation.
Welcome to StackOverflow. As best I can determine you cannot rename a GitHub Wiki page without its markdown file also being updated to the new name. The two are tightly coupled.
This Web Applications (StackExchange) Question has some alternatives you may consider, i.e. instead of renaming the page, create a copy. Then edit the original page so that it directs visitors to the new page via a link. This way the original page link remains valid but directs visitors to the new page.

Github prepends "https://github.com/user/repo/blob/main/" to all links in readme.md

I have a private repository on GitHub that contains a readme.md file with links to Kaggle datasets. When viewing the repo on github prepends "https://github.com/{user}/{repo}/blob/main/" to the url, breaking it.
Why is this happening, and how do I change this behavior?
For what it's worth, I'm also using git-lfs, though I can't find any documentation of this behavior associated with that, either.
I ended up figuring this out on my own. The URL was missing a scheme, and github was treating it like a relative link to something in the repository. This was my mistake and not an issue with github.

Github Pages with Sphinx generated documentation not displaying HTML correctly

I have been trying to publish a Sphinx generated documentation for our repository on Github pages with the theme provided by readthedocs.org.
After a few attempts I managed to get it online by uploading the Sphinx generated HTML files in the gh-pages branch of the repository.
Obtaining this:
https://takeqontrol.github.io/qontrol_api/
Which is looking awful, erasing all the customization of the theme by Read the Docs.
Here is an example of what you see if you open the link:
But if I open those HTML files on my computer the pages looks exactly how I wanted them to look.
Here is an example of how exactly the same HTML looks locally:
Does anybody know what is going on? Or even point me somewhere where I can find an explanation?
All the code is available here: https://github.com/takeqontrol/qontrol_api
in the two branches.
I fought with this for 9 hours before figuring out that the underscore in the _static folder was causing the issue.
You need to by pass Jekyll on github pages.
To do this, add an empty .nojekyll to your gh-pages branch. (See example)
I was having a similar issue and then found this, which solved it for me:
Python Sphinx css not working on github pages
Looks like using underscores for the _sources + _static folder caused the issues. Need to rename the folders and paths using them in the html files accordingly.

GitHub changelog links to commits

Some projects have a CHANGELOG.md file where each version links to the range of commits that were made for that version. For example, this one. It looks like these links are automatically generated somehow, because the markdown only contains [1.0.0] where the rendered document has a link to https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0.
How does that work? I've tried to do something like this on my own project, but the rendered document just said [1.0.0]; no link was generated.
Presumably it has something to do with the tags, which follow a similar pattern (v1.0.0), but when I tried to create similar tags in my project, it still didn't work.
I also could find no reference to this on the GitHub help, or anywhere else for that matter.
Is this indeed an (undocumented?) feature of GitHub? If yes, how does it work? If no, how do these projects do it?
Note, I'm not interested in automatically generating a changelog from commits like this project does. I'm just interested in the mechanics of these hyperlinks.
You need to look beneath the surface of the Markdown, it's a simple trick he done by using the file compare feature to compare tags.
If you look at the RAW file, you should notice at the bottom he added links to each version number that has a compare link assigned to it.
## [1.0.0] - 2017-06-20
[1.0.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...v1.0.0
With pretty mode, you would see the link to the compare page.

GitHub: Linking to an issue from a wiki page

On GitHub, is there a simple way to reference an issue (eg: #1234) from within a markdown file such that it is displayed as a hyperlink?
I don't want to write out the full form each time, as in:
[#1234](//github.com/user/project/issues/1234)
In commit messages, issue numbers are automatically hyperlinked. Can this happen in wiki documents too?
(This is not a duplicate of this question which is simply asking about markdown hyperlink syntax.)
It doesn't happen in wiki documents.
You can use a relative url but it isn't that much of a shortcut. It also depends on where you are in the project.
For example in the Readme.md in the master branch of the project:
[#1](../../issues/1)
On the github wikis:
[#1](../issues/1)
Anywhere:
[#1](/user/project/issues/1)
(h/t to VertigoRay for suggesting this)