The basics of Git & GitHub

Photo by Yancy Min on Unsplash

The basics of Git & GitHub

Everyone knows Git, but not everyone knows everything about it. We all know how to commit and push, but what about forks, branches and pull requests? Those are mostly for collaboration with others as opposed to a solo project, or just multiple publication branches (eg. alpha/beta & publication). Except for forks, you can reasonably use all of these without needing other collaborators. Another feature on GitHub is starring repositories, but those are just publicly saving repositories for later.

I won't discuss the very basic parts like setup, committing, and pushing as there are lots of videos on that. Instead, I'm going to go over basic collaboration features.


Forks are exclusive to GitHub and related websites, and they lead directly into pull requests. You copy the repo to your account, then edit it. When you edit it, all of your changes can be put into a pull request to merge those changes with the main repository. On GitHub, above the file explorer, you would see a message that looks like this. image.png On the other hand, when you update the repository, you now see this. image.png Nothing you did here carries over to the original repository until you decide to open a pull request from that bar by going to Commit -> Open Pull Request. There is no comparable command for forks.

Branches are, as the name suggests, separate branches. They are their version and can be merged with other branches like this. image.png They can be used for release channels (alpha, beta, production, etc.), they could be used for collaboration, etc. Another use case of branches is the cryptocurrency blockchain. When someone tries to make a change to the ledger and it gets verified, a new branch is created. But, if it fails and the main branch succeeds due to not being long enough, it gets deleted. The command for this is git-branch

Pull Requests are also exclusive to GitHub and related websites. They allow the owner of the repository to merge commits on branches or forks to other branches on the main repo. There are 3 main types, merging adds all commits, squash merging combines all commits, and rebase merging combines all commits individually. Each of these results in the head branch getting deleted. The related command would be git-merge.


Git is a really simple yet advanced tool and is crucial for any developer. There are lots more commands that you can find on the Git documentation, but the main ones that you need to know are -commit, -push, -fetch, -branch, and -merge.


I am always open to article suggestions, just join the BiteSizedCode Discord server.