The WHY?
If you are not a fan of cringe funny self thoughts then you better run to the table of contents right away, because I am not even sure how long this blabla-kind-of-introduction will be.
To give you a brief overview about the WHY I am even writing this post, I recently joined a coding club focusing on students who identify as FLINTA, hoping to talk about javascript/typescript, but it turns out that most of our members are interested in python, R or C. Well, I am not proficient in any of those. So I was thinking, what else could I do a workshop or talk about that would be interesting and valuable for everyone? What connects programmers? And then the light bulb appeared above my head: Collaboration tools?! Git!
But of course the way I am, I don’t want to just hold a boring workshop where I am talking and hoping that everyone keeps up. I want it to be interactive, fun and easy to digest (mentally). I want the people to get inspired, even make mistake but get a sense of how to deal with them. I think its possible, but difficult. That is why I thought, why not document it. It might be a fun challenge for me to finally write and maybe it will be easier to spot some common topics I can re-use for future workshops or even reflect upon.
Also, just to be clear, I am taking this as an opportunity to learn Git more in-depth.
Table of Contents
- Back to the future
- Installation
- It all begins with init
- Tree of life
- On stage
- Committing doesn’t have to be hard // PUSH to github
- Merge chaos
- Summary
- Resources
PS: This is a living article and will be finalized along the workshop content.
Back to the future
Imagine working on a file—perhaps your CV, an image, or a homework assignment. The first version is saved as file.pdf
,
which seems straightforward. But as you make slight changes, you save a second version as file1.pdf
, then file2.pdf
, and so on.
Over time, you end up with a huge mess of files, not knowing which version is the most recent or being able to understand what changes
were made and when. You might even accidentally delete or overwrite important updates.
Ok, and now to spice it up— imagine, collaborating with someone on the same file. Things get even more complicated. Changes might get overwritten, someone from the team might even accidentally delete a key section.
And of course if we are talking here just about a single file, but what if we were working on a huge application source code? Managing changes, collaborating effectively, and keeping track of every version becomes nearly impossible without the right tools.
This is where version control systems like Git
come in handy.
They help you manage and track changes, and collaborate seamlessly even on complex projects.
You can think of Git as a time machine, that allows you to see you past modification and even revert files to a specific version when needed.
Git x GitHub
I think especially when you are completely new to the version control mechanism it is easy to assume that GitHub and Git are the same thing.
However they are different: Git, as we discussed, is a version control system, while Github is a platform that uses git to host and manage projects.
So just like with our example before, sharing your source code with other developers requires it to be stored/hosted somewhere, so everyone can access it. GitHub is one of the options you can use to host your code as it has a very user friendly UI (user interface) and provides really cool features, like Actions (which I might cover in another post).
Installation
Before installing a new version, check if git is already on your device:
If it is, you will see the version of your git. If not you might see something like command not found: git. In that case:
- Install git
- Set your username
- Set your email address
It all begins with init
Now that we have established a general understanding of what git is used for, let’s dive deeper into a practical example.
For demo purposes I am going to create a small deno project with a single file main.ts
which just logs Hello Git!
After running deno run dev
we will correctly see the console log.
Our first task is to create a repository, which is basically a project with all the necessary meta data in order for git to know how to track your files.
In order to create a repository, we need to run the initialization command:
By running this command you might not see any changes as the git metadata are stored hidden files. But if you navigate to your projects and
hit Command+Shift+Dot
(MacOS)/ Ctrl+H
(Windows)/ ls -a
(Linux Command Line) you will see a folder called .git
.
When running the status command, you will see that at this point no files are being checked for changes yet.
On stage
To start tracking your files you need to run the add command as follows:
The dot will add all untracked files to the staging.