Chapter 1. Local Git

 

This chapter covers

  • Why Git was created
  • Creating a new local Git repository
  • Committing files into a Git repository
  • Viewing the history of a Git repository
  • Using gitk/GitX to visualize the history of a Git repository
  • Viewing the differences between Git commits

In this chapter, you’ll learn how and why to use Git as a local version control system. Let’s start by learning why Git is so widely used by programmers.

1.1. Why do programmers use Git?

Git was created by a programmer to be used by programmers. Linus Torvalds, the creator of the Linux kernel, started writing Git in 2005 with the goal of having a distributed, open-source, high-performance, and hard-to-corrupt version control system for the Linux kernel project to use. Within a week, Git’s source code was hosted inside the Git version control system; and within two and a half months, version 2.6.12 of the Linux kernel was released using Git.

Since its initial creation for the Linux kernel, Git has come to be used by many other open source projects, all sizes of companies, and large “social coding” Git hosting sites such as GitHub.

1.2. Initial setup

1.3. .git subdirectory

1.4. Creating a new commit: git add, git commit

1.5. Rewriting history

1.6. Diff formats

1.7. Refs

1.8. Summary