How Git and Github can make your life easier

isabel k. lee
The Startup
Published in
5 min readMar 30, 2020

--

Have you ever been deep into a project and realized midway through that there was a glaring mistake? Maybe you deleted an important note in your essay and it was too late to go back. Or you merged all your Photoshop layers and you couldn’t edit those precious text layers anymore…

Well, I’m here to tell you that using a version control system can save you from that pain! Creating new copies of your work, while safely storing the original version, can help you avoid a lot of tears and late nights. Integrating a robust version control system, like GitHub (for developers) or Abstract (for designers), can help you experiment with new ideas, track changes in a project, and collaborate with teammates more seamlessly.

Example of how to collaborate with a teammate using Git.

What the heck is Git? And what’s GitHub?

If you’re a developer, or work closely with developers, you’re probably going to hear about Git and GitHub a lot. They are some of the most powerful version control tools you can use to organize your code.

So let’s break down what they can do!

Git is a version control system that comes pre-installed on most computers. It’s a lightweight, local tool that you can access through your computer’s command line (which is the Terminal app on a Mac, or Windows Terminal for PC users). Git is an essential tool, regardless of the stack you specialize in or how many years of experience you have.

GitHub is a visual, online representation of Git. It’s built on top of Git and has a lot of extra functionality. You can create and host multiple projects (also known as repositories or repos) on GitHub, invite collaborators, and write documentation about your code.

The same log of commits shown on Git vs. GitHub.

Unlike Git however, GitHub has a number of competitors. There are other hosting systems like Bitbucket and GitLab that are also built on top of Git. While GitHub is the most commonly used hosting system, that doesn’t necessarily mean it’s the best.

At the end of the day, Git and GitHub have a symbiotic relationship. If GitHub were a car, then Git would be the engine. The engine is a necessary tool that powers the car, but the body allows it to do other things, like play music or open the sun roof.

Getting started

Before you learn how to use Git and start organizing your code, you have to create a repository (or project folder) on a hosting system like GitHub. This is because Git needs a central repository to “talk to” in order to save your project.

How to get started:

  1. Create an account on GitHub.

2. Create a new repository on GitHub.

3. Clone the repo onto your computer using the Terminal app.

How to create a new repository in GitHub and clone it to your machine.

4. Start coding in your preferred text editor!

5. Create new branches (versions) as you go, so that your master version (the original) stays untouched.

An example of creating a new branch using Git in the terminal.

6. Create commits for any changes you want to document.

7. Push those changes back to GitHub.

The new branch in Git is pushed to GitHub.

8. Once you feel satisfied with your new work, merge your branches into master.

9. Now your master branch has been updated and you can continue the cycle!

Conclusion

Whether you’re working on a solo project or collaborating with a large team, integrating a version control system into your work flow can be hugely beneficial. Not only does it help you track your work from start to finish, it can also teach you to share your work in a more transparent manner.

Combining your knowledge of Git and GitHub with learning how to write clear, intentional documentation can make you a better developer and collaborator.

The best software is rarely written by one person, so it’s important to know the tools used for working with others!

Terminology

Commits are checkpoints that you can save when you’ve made a change to your project. If you’re not happy with the direction you’ve gone in, you can always go back to a previous commit and restore your work.

Make sure to write clear, concise messages for your commits, like “Add X functionality to Y feature,” instead of vague messages like “update” or “BAD BUG.” Vague or unhelpful commit messages can create a muddy picture for why your code was changed and what you worked on. The point of a commit message is to capture the intent behind the code.

Branches are different versions of your code. The master branch is the original, and should never be worked on directly. Branches allow for robust collaboration by letting teammates create their own versions of the code.

If you’re working on a solo project, branches should be created with intention, like every time you build a new feature or tackle a small part of your project.

Repositories, otherwise known as repos (“REE-POHS”), are projects. They’re like folders that house files (and sometimes subfolders) of code.

Merging a branch means that you are combining different versions of your code. Merge conflicts can happen if you and your teammate worked on the same feature, but wrote different code. The good news is, you can analyze your divergent code line by line, and see which version you want to keep.

Pushing a commit means that you are sending your changes back to GitHub. When you make commits on your computer, they only live on your local machine. Pushing is a necessary step in updating your code on GitHub’s side as well.

--

--

isabel k. lee
The Startup

sweet, technological baby with a magic bag // www.kleetime.com // they/them 🏳️‍🌈