How Does Git Work? In a Nutshell …

Git is a file versioning system. It’s older than you or I so it’s not worth delving into it’s depths and resolving it’s mysterious ways. For now, it’s totally best to just know: it keeps multiple versions of your files. This guide doesn’t aim to give a perfect picture of Git, but just a clearer idea of how we use it, so don’t take this as the gospel truth about Git. It’s just another way to look at what it does.

If I had to describe it in a nutshell …

How do I use it?

You download and install it like any other program, such as Skype or Hipchat. Just know that it’s a program you run on your computer and that it keeps documents in a repo for you, saving each version so you can call have them at your disposal.



So do I need to use Github?

Think of Github as a sort of Dropbox for your Git repos. Github is just a place to host and share your repositories.

Where are the repos on my computer?

They’re in those secret places in the Git program. Your repos are on your computer, nicely tucked away inside the Git program in super compressed, unreadable files. Your repos are not online (unless you upload them). They are on your computer inside the Git program.

How do I save my work?

Commits. Git works like this:

  1. You save whatever you’re working on to a folder on your computer.
  2. git init : You tell the Git program to treat that folder like a repository for version control.
  3. git add : You use the terminal (cli) to add files to your repository. This tells Git what to monitor or ignore.
  4. git commit : Command git to save a new version of your files to the repository and log it in the file history.
  5. git push : Send your repository to another computer.
  6. git pull : Retrieve external changes to your repo from another computer.
  7. git clone : Add an external repository to your computer.

In practical terms, this is why all it takes to change an ordinary folder into a repo is a .git folder, which basically just contains instructions for handling the files. This is also why deleting the .git folder completely removes the repository without harming your files.

This also why commits are different from pushes. Commits update your computer. Pushes update the files on a different computer.

And that’s Git in a nutshell.

Leave a Reply

Your email address will not be published. Required fields are marked *