GitHub

Share

What is GitHub?

GitHub (github.com) is a website for programmers, where source code of applications and other software can be publicly (or privately) shared to other programmers. Unfortunately, lately GitHub has been being used to share applications with end users, who have no business being in GitHub at all, leading some to wonder "where is the .exe?" when they're given a link to a page about code.

For the record, before GitHub became popular, we had SourceForge to share open source applications, which was and still is much better, since it actually has a download button in the front page of a project to just download the .exe.

Note for programmers: if you didn't set up a basic static website using github.io instead of linking straight to the repo, you're to blame for this. It's HTML. It's practically English. Just start a file with <div style="text-align: center"> and you don't even need CSS.

What is Git?

GitHub is based on a set of programs for managing source code called git. Much of the terminology used in the GitHub stems from the git program.

In git, source code is placed inside a "repository." Changes to the code are committed to this repository. Each commit has a "commit message" and is assigned a hash that validates its integrity. Normally, to validate that something has integrity, we would need to check the entire data, however git uses a strategy popularly known as a "blockchain" to quickly validate changes: each commit includes in its hash the data of the previous commit's hash, creating a chain of hashes-of-hashes. This means we can start from a point that we know is valid and only validate the next blocks of the chain instead of having to validate the entire thing.

In git, you would run git init to initialize a repository. git clone is used to download a repository from the Internet and setup its origin automatically, so that git push will send the changes back to the Internet. git commit commits changes to the repository. git branch creates creates a branch (i.e. a fork) of the current repository history (the default branch is called master as in "master record," although some call it main instead). git checkout switches which branch or commit is currently being edited. git stash saves the changes to a separate space without committing them. git merge is used to merge two branches.

What is a PR?

A PR (or pull request) is a request a programmer makes so that the maintainer of a repository "pulls" their changes to the code. For example, say that there is a typo in an application. I can create an issue that says "there is a typo in here," and maybe someone who can modify the official code will see it and fix it, or maybe it will takes 2 years for that to happen, who knows. Or I can fix it myself and then send create a PR.

In the latter case, I would have cloned the repository to my computer, so I'd have all the code I need to recreate the application. I'd fix the bug. Recreate the application. Make sure that I somehow didn't break things instead of fixing them. And then the application would be fixed for me. I could create a "fork" of the application with my own fixes and distribute them through the Internet. Open source licenses like GPL allow me to do so. However, if I want everyone to enjoy my fix, it makes more sense to have the fix merged in the official repository where everyone downloads the code from.

Since I do not have authority to change the official code, I need to make a PR with my fix. Then someone with authority to merge code into the repository (e.g. the maintainer) needs to approve my PR.

Ideally, this means they would look at the code I wrote and check what lines of code I changed, added, or removed, to make sure I didn't add anything malicious to the code that would then get distributed to everyone. Because the PR needs to be checked by a human being, who is probably working on an open source project on their free time, it's important to keep them as small and focused as possible, and document the changes in plain English, too.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *