'Checkout a specific revision with Git' post illustration

Checkout a specific revision with Git

avatar

If you have a project and want to checkout specific revision (commit), you can do it as described below.

1) Clone the project:

1
2
$ git clone https://github.com/<organization>/<project>.git
$ cd <project>

2) Use the git describe command to get readable name for your commit. The git describe will first look for a tag which tags exactly that commit. If an exact match was not found, git describe will walk back through the commit history to locate an ancestor commit which has been tagged. The ancestor’s tag will be output along with an abbreviation of the input committish’s SHA1. You can read more about this command here.

1
2
$ git describe 5f6ba67e3f8cb59cb9a2f4db22f12e55326a182d
kors-2757-g5f6ba67

3) Checkout the specified revision:

1
$ git checkout kors-2757-g5f6ba67

4) You can go back to the top with:

1
$ git checkout master

If you're looking for a developer or considering starting a new project,
we are always ready to help!