Whether you’re an advanced coder or a beginner, there will come a point when you want to show other people your code — whether to get advice or simply to show off a cool project you built.
In the past, the main way to transfer your code would be through email. But that’s slow and clunky. As well as the issues involving file size, amount of files, and sometimes even the type of file. Alongside that, if you update your code, you have to save a whole different version of it, if you want to keep the original, and email it over and over.
This is where Git and Github come into play and truly shine!
Photo by Roman Synkevych on Unsplash
I’m going to explain what these tools are, there benefits (mainly in regard to version control and storage), and how to quickly get setup and upload your first project!
What is Git / Github
Git, at its core, is a tool for version control. Basically a way to track changes made to code. If you did any work on computers in the past — coding, writing, graphic design, etc — you’ll remember doing something like this!
This is the core of Git. To setup a line that allows for you to update changes and create a commit, almost like a checkpoint, that you can refer to or convert back to if needed.
As for Github, it is the same as Git but in the cloud. Git is the tool you use on your local device for version control, but it really shines in the cloud. You are able to, not only make different saves of your work, but you can upload them to the cloud for anyone to see. And it doesn’t just upload them like a folder or zip file like Google Drive or Dropbox, instead it uploads all the commits and other changes.
This is a great tool for working on teams! One person can do a part of the code, make a commit locally for themselves, then push (upload) it to the cloud where teammates can immediately see all the commits. Not only that, but you also can see what files were changed, what code was added and removed, and so much more!
Benefits
There are many many benefits to Git and Github, but I am only going to focus on the two I find most important: Version Control and Storage.
You can find more benefits explained here:
Version Control
Few things feel worse, at least as a coder, to accidentally exit your code and it doesn’t save. Worse yet, when you decide to change one little snippet and the entire code breaks.
Tragic.
But that little code you wanted to change is necessary! You need to update the database settings or change a HTTP route. Maybe optimize your machine learning algorithm to be more accurate. But it requires you to change things in your code base that may not 100% tie into the change your making. You don’t want everything you’ve done before because, what if your new changes turn out to not work or are no longer needed? You pivot and now you need to go back to what worked?
That’s Version Control.
The ability to make savepoints in your code so that, if you make a mistake or don’t want to continue testing something new, you can go back to a version that works.
For example, the same way you can update an app on your phone, and then it stops working because it’s no longer compatible with your phone, so you have to revert to an older version. That’s a form of version control.
You can also create branches, although most don’t unless they are working on a larger project or team, to test different ideas without altering the main version. For example, I am working on building a website. Everything is working on the main branch. But I want to try this new homepage design with cool animations. I know it could possibly conflict with my original idea, which does work as is.
So instead Imake a branch, like a fork in the road, that is a copy of the code I already have, but allows me to change it and make new paths/commits without altering the original code.
Photo by Yancy Min on Unsplash
In the image to the left, there are a list of commits that have been made. You can see the main branch is the blue line. The green and pink lines are both their own branches. They stem from the original path and, especially in the case of the pink, have their own commits (dots) as well.
Later, you can either merge the branch into the main one, or you can delete the branch if you don’t need it.
Storage
Anyone remember Floppy Disks? Or Flash Drives? Portable Harddrives?
All ways to store your data and keep it with you as well as transfer it to other places. Today, those methods are still used, but it is faster, and less likely to get lost,to use cloud services such as Google Drive or Dropbox. But, for the best look for code, Github is the place to go.
As alluded to before, on Github.com you can upload your code directly. Whether the individual file or the entire folder of files, images, videos, etc. it can all go here. I know I personally have over 100 repositories on my github and more are to come.
The true gem in its storage is its ability to quickly and easily share code with others. Say you want a peer to look and your code and review it, or to show them this cool function you built, you can just tell them the name of the repository and they can click and look on their end. No need to compress and email files, taking up more space on the sending and receiving end.
Not to mention the layout is built for code; Whereas using another cloud storage platform will require you to add an extension to be able to properly read and format the code. You can see the difference in readability, keyword highlighting, and spacing from using Drive (left) vs Github (right).
Couple this storage ability with the version control, so you can store previous versions and builds of code you’ve tried, and why wouldn’t you use Github?
Since I started using it a few years ago, it has remained my goto for where to showcase my code online. And with all of it support, features, the ability to follow others, and it collection of resources, I am interested to see how it grows over time.
Stay tuned for articles on how to get started with setting up and using Git and Github!