What is a Git Checkout?

What is a Git Checkout?

About

With a checkout, you can

Specifically, it will check out the files

Checking out a local branch from a remote-tracking branch automatically creates what is called a tracking branch

Example

Switch branch

git checkout branchName

Restore a file 2 commits back

Restore the Makefile to two revisions back from the main branch

git checkout main~2 Makefile

Restore all unstaged files

For all unstaged files use at the root dir:

git checkout -- .

Restore a specific file

git checkout path/to/file

Restore a series of file and directories

git checkout main -- {path/to/dir,path/to/dir2,path/to/file.json}

Support

error: pathspec '.' did not match any file(s) known to git.

Do you perform the checkout from the root directory ?





Discover More
Git - Local branch

A local branch is a branch that exists only on your computer. tracking branch There are two types of local branches: non-tracking local branches. They are not associated with any other branch....
Git - Tag

This page is tagging in git Git has the ability to tag specific points in history as being important. Typically this functionality is used to mark release points (v1.0, and so on). Git uses two main...
Git File Lifecycle
What is the Git File Status?

The status of a file in a working directory is one of: where: State Tracked Description untracked New file unmodified Tracked File is the same as in the last commit modified Tracked File...



Share this page:
Follow us:
Task Runner