git, explained

Everything you need to know to understand how developers build software.

Tom Parandyk
5 min readNov 3, 2019

This is a mac tutorial

Did you ever want to make a simple text changes in your app, but didn’t have access or was worried you will break something?

Did you ever want to have an insight into how your development team works?

Here’s git explained.

Git is a version control protocol.

Git protocol is used by code hosting platforms like GitHub or BitBucket. These are like Dropbox but designed specifically to host code online.

Developers use git to work on the same files in a very similar way to how Google Docs keep the version history when text is edited in a document.

The difference is that in Google Docs everyone logs in and works on the same document hosted in the cloud. You can do that in GitHub as well by going to the document in the browser and edit its online version, but most developers would make changes to the files located on their computers, called local , and send the changes in batches to the online repository, called remote.

That’s when the conflicts might happen. You probably heard your dev team talking about conflicts a lot.

A conflict is when more than one person makes a change to the same line of code in the same file.

Git helps find those conflicts and shows them as part of a diff .

Diff is a difference between the online version of the file and the new change submitted by another person.

Let’s say you work on the same git repository with your friend.

You both pull the latest version of the remote code. Now you both have it on your local computer and can start making new changes.

Say, your friend pushes new changes to the remote first. Now, the new remote is different than the one you have on your local. What happens when you both made changes to the same files and now you want to push to remote?

You get a conflict 😱!

That sucks, but it’s not the end of the world. Conflicts have to be resolved.

Git is handy because it automatically tracks all the files and shows the conflicts as two versions asking you to pick one that should be kept.

Once you select either your version or the version that was pushed by your friend and push, the remote will be successfully updated.

A quick way to recognise if a project (folder) is a git repository would be to show the invisible files in your finder and look for .git folder.

FYI, .gitingnore file holds a setup of files or folders that are not tracked and stored in the online repository.

You might also hear your dev team speaking about branches. 🌲

Git branches provide a way of sharing different versions of remote without affecting the remote directly.

The main branch, we called it remote up until now, is also called master and stands for the trunk of the git repository.

One of the main goals of the branching system is to enable contributions to master without breaking it.

There are two ways to merge new changes to master:

  1. You can git push directly
  2. You can create a PR (Pull Request)

Pull Request is a message in git that includes:

  • All the changes added (committed) to a branch
  • Tagged users who should review the changes
  • Comments and merge settings

You can preview open Pull Requests in your git repository.

If you can see any items in PR list it means that those changes have not yet been merged to the master.

😎 INSTANT XP BOOST: If you want to keep following the actual development progress it’s important to understand what was merged and what changes are still under review in the open Pull Requests. Sure, you can ask, but it’s faster and doper to just go and read the commit messages directly in the repository.

One important concept you should get yourself familiar with is a production branch.

“M” stands for “Merge”

Production branch is the code that makes the app your users see and interact with. Pushing and merging code from the master branch to the production is often called a release.

Important installation steps you have to complete to be able to use git commands on your computer:

  1. Go to Applications > Utilities > and open Terminal App
  2. Copy and paste these two lines of code /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    Press Return to run.
  3. Next, copy and paste brew install git . Press Return.

You are ready to clone and commit to git projects 🚀

👏 if you find it useful

--

--

Tom Parandyk

Product designer, eager engineer, strategist, wild innovator, proud dad, creative leader, aspiring musician.