Tools & Tips

Git Succinctly: Git Overview


Each Git repository contains four components:

  • The working directory
  • The staging area
  • Committed history
  • Development branches

Everything from recording commits to distributed collaboration revolves around these core objects.

The Working Directory

The working directory is where you actually edit files, compile code, and otherwise develop your project. For all intents and purposes, you can treat the working directory as a normal folder. Except, you now have access to all sorts of commands that can record, alter, and transfer the contents of that folder.

Figure 2: The working directory
The working directory

The Staging Area

The staging area is an intermediary between the working directory and the project history. Instead of forcing you to commit all of your changes at once, Git lets you group them into related changesets. Staged changes are not yet part of the project history.

Figure 3: The working directory and the staging area
The working directory and the staging area

Committed History

Once you've configured your changes in the staging area, you can commit it to the project history where it will remain as a "safe" revision. Commits are "safe" in the sense that Git will never change them on its own, although it is possible for you to manually rewrite project history.

Figure 4: The working directory, staged snapshot, and committed history
The working directory, staged snapshot, and committed history

Development Branches

So far, we're still only able to create a linear project history, adding one commit on top of another. Branches make it possible to develop multiple unrelated features in parallel by forking the project history.

Figure 5: The complete Git workflow with a branched history
The complete Git workflow with a branched history

Git branches are not like the branches of centralized version control systems. They are cheap to make, simple to merge, and easy to share, so Git-based developers use branches for everything-from long-running features with several contributors to 5-minute fixes. Many developers only work in dedicated topic branches, leaving the main history branch for public releases.

This lesson represents a chapter from Git Succinctly, a free eBook from the team at Syncfusion.

Related Posts
  • Game Development
    Git and GitHub for Game DevelopersGit and github for game developers 400px
    "I'm sure Git is great, but it looks complicated - I'll stick with my current workflow" is like saying "I'm sure IDEs like FlashDevelop and Sublime Text are great, but they look complicated - I'll stick with Notepad". Yeah, sure, there's a bit of a learning curve, and you can live without it, but it's foolish to. In this article, I'll explain why Git (and GitHub) is so great, and show you how to get started quickly and easily.Read More…
  • Code
    Tools & Tips
    Git Succinctly: Getting Started With GitGit succinctly cover 400
    Installation Git is available on all major platforms. The instructions below will walk you through installation on Windows, but it's always best to consult the official Git Web site for the most up-to-date information.Read More…
  • Code
    Tools & Tips
    Git Succinctly: Recording ChangesGit succinctly cover 400
    Maintaining a series of "safe" revisions of a project is the core function of any version control system. Git accomplishes this by recording snapshots of a project. After recording a snapshot, you can go back and view old versions, restore them, and experiment without the fear of destroying existing functionality.Read More…
  • Code
    Tools & Tips
    Git Succinctly: BranchesGit succinctly cover 400
    Branches multiply the basic functionality offered by commits by allowing users to fork their history. Creating a new branch is akin to requesting a new development environment, complete with an isolated working directory, staging area, and project history.Read More…
  • Code
    Tools & Tips
    Git Succinctly: Remote RepositoriesGit succinctly cover 400
    Simply put, a remote repository is one that is not your own. It could be on a central server, another developer's personal computer, or even your file system. As long as you can access it from some kind of network protocol, Git makes it incredibly easy to share contributions with other repositories.Read More…
  • Code
    Git for DesignersCode
    You're likely familiar with tools, like Git and Subversion. But, as web designers, it's quite possible that, though you might say you leverage version control in your projects, the truth is that, more often than not, you simply don't.Read More…