WebLabs 05 | Version Control with Git

Git is an open source distributed version control system (VCS). The purpose of version control is to record changes to a file, allowing you to recall previous versions of those files. In a VCS, you can revert a single file or a project back to a previous state, compare changes over time, or see what modifications have been made (and by who!). The VCS allows you to roll back and recover to previous versions.

When you commit your files or save the state of your project in Git, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. If there have been no changes to the files, Git doesn’t restore the file, just a link to the previous identical file.

Git has three main states for files:

  • Modified: You’ve made changes, but have not committed the file
  • Staged: You’ve got a file ready to be committed
  • Committed: The data is safely stored in your local database

Read Getting Started – About Version Control from Git

Read Getting Started – Git Basics from Git

Git Building Blocks

  • A fundamental building block of Git is the repository, or “repo”; the place where your project files and track changes are stored. There are two repositories: Local and remote. You work on your files in a local repo and then sync to the remote repo.
  • Committing is the way you bundle your changes (also referred to as a “signpost”). It’s a record of accomplishment, and could include a bug fix, a new module or markup, or even a set of finished changes. It represents a project state that you might want to return to.
  • Git allows you to create alternate timelines for your files and merge them into one another. This concept is called branching, the key to collaboration and team workflow. For example, let’s say you and your team are working on a website.
    • Our main branch represents production, the current state of the website. The team has been asked to include some new features to the site.
    • They create a branch off of the main branch to make the revisions.
    • The developers working on the revisions only work on the branch.
    • The developers working on the production site are still working on the main branch.
    • When the revisions on the branch are complete, the branches are merged together.
  • Pushing and pulling: You push changes to the remote and pull changes from the remote.

Using Git

There are a number of different ways to use Git – either by command line or GUI (graphical user interface) tools created by other software companies or open source providers. A commonly used platform for collaboration is GitHub, where developers can jointly share and work on their projects. GitHub can be used for any type of file sharing, not just code files.

If you don’t want to run command line Git, you can use a GUI like GitHub Desktop or SourceTree. You also have options for remote repository hosting: Two of the most popular are GitHub and Bitbucket. Here’s a link to an article that compares the two. One advantage of Bitbucket is that you can have up to five users with unlimited private repos. GitHub’s free plan only includes public repos but unlimited collaborators.

Why Would I Want to Use Git?

Version control and collaboration: Many major open source projects (and even commercial projects) use Git for worldwide developer collaboration. Many file repositories are available for users to download and either use (like code examples) or contribute to. For example, check out Mozilla on GitHub.

Git for Your Group Project

It’s not required to use Git for your team project, although you may find that it is an effective way for your team to collaborate and share files.




GitHub Help

Git & GitHub Learning Resources

YouTube GitHub Training & Guides


Video Tutorials