Git Overview

What is Git?

Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems).

Why do we use it?

  • To download projects to our systems.

    • Try cloning the following to a read-only directory in your workspace:
      $ git clone <clone-link>`
      
      • After cloning is complete, you will need to cd into the directory.
    • Example repos
  • Code backups: Git allows you to take snapshots of a directory (commits) which we can rollback to in case we royally screw up.

  • Syncing code: If you work on two machines, like a home laptop and office system, you can use Git to sync your projects.

  • Collaboration with teammates: Git allows multiple developers to work on the same file at the same time. Conflicts will happen but Git helps resolve them.

  • Deployment: In industry, we use Git to sync our project code with a server to make it live.

How does it work?

  • At the end of the day, Git keeps track of each line of code in your project, including:
    • who created it.
    • every change made to it
    • who made each of those changes and when

First-time Setup

Extras

Common Errors

  • Troubleshooting common errors

  • Forgetting the -m "commit message" portion of a commit will open vim (or whatever command line text editor is set up) and you'll see a screen like this: Forgot a commit message

    • If this happens, it's easiest to just quit vim by typing :q! (see: vim cheat sheet)