Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is git checkout named like that?

Tags:

git

From what I understand, git checkout changes the state of files in the current directory to what it was at a specific point in the tree. Hence it can be used to switch branches or to visit a previous commit.

Why was the name checkout chosen for this operation?

Is the analogy to "I'm going to go check this out"?
Is it to checking out books from the library?

I'm not asking whether the name is a good idea or not, or trying to offer judgement on that myself -- I'm just wondering what the historical origin of the name is.

like image 381
Eli Rose Avatar asked Mar 22 '16 18:03

Eli Rose


People also ask

Why is git checkout called Checkout?

DESCRIPTION Updates files in the working tree to match the version in the index or the specified tree. If no paths are given, git checkout will also update HEAD to set the specified branch as the current branch. checkout (co): Check out a working copy from a repository.

What is the meaning of git checkout?

In Git terms, a "checkout" is the act of switching between different versions of a target entity. The git checkout command operates upon three distinct entities: files, commits, and branches.

What does git checkout filename?

1) Undo uncommitted changes using git checkout --<filename> It rollbacks any content changes to those of the specific commit. This will not make changes to the commit history. Use this to move the HEAD pointer to a specific commit or switch between branches.

What is the difference between git checkout and Branchname checkout?

git checkout -b BRANCH_NAME creates a new branch and checks out the new branch while git branch BRANCH_NAME creates a new branch but leaves you on the same branch. In other words git checkout -b BRANCH_NAME does the following for you.


2 Answers

Much of this is historical. Pre-git version control systems (VCSes) used the verbs check in and check out as well.

An excerpt from a book I'm working on:

Used as a verb, to version means to put under control of the VCS. Used as a noun, version means a specific version taken from the VCS (of one file, or of a group of files). Usually the noun form appears with additional modifiers, as in the phrase the old version of kanga.c or version 2.1 of roo.c. If no specific files are listed, we typically mean everything, or at least everything recently under discussion: version 2.1 (of everything in the repository, or of the specific files and/or directories we were talking about). The word revision is always a noun, but otherwise means the same thing as version.

Another verb, to check in, means to store into the VCS. As you might expect, if we can check in, we can also check out, meaning extract from the VCS. Some VCSes add the verb to update, which they may use to distinguish between extracting an older version (which you check out) and moving up to the latest and (we hope) greatest (to which you update). Mercurial uses update as a pure synonym for checkout.

like image 123
torek Avatar answered Sep 28 '22 03:09

torek


I assume the one who can tell you where the name came from Is Linus Torvalds who developed git.

Based up on the action which checkout does - switching the content of the working directory i can only assume that the origin of this word is like what you have described

Checking out book from the library

From the documentation:
https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html

git-checkout - Checkout a branch or paths to the working tree


Links:

  • Pack files: https://git-scm.com/book/en/v2/Git-Internals-Packfiles
  • Checkout: https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html
like image 34
CodeWizard Avatar answered Sep 28 '22 04:09

CodeWizard