git checkout <hash>         # non named commit
git checkout <branch_name>  # named commit

The two lines above will place the HEAD pointer on the given commit. You should know that a branch name is a commit, except it can evolve if a new commit is added when you're on that branch.

If you want to place your branch Dev on the commit ad4f43af43e you can do this

git branch -f Dev ad4f43af43e

Be careful! This is dangerous because you may lose commits.

Answer from smarber on Stack Overflow
🌐
Git Tower
git-tower.com › learn › git faq › how to checkout a commit in git
How to Checkout a Commit in Git | Learn Version Control with Git
5 days ago - With the git switch command (or, alternatively, the git checkout command), you can simply provide the name of the branch you want to checkout. This branch will then be your current working branch, also referred to as "HEAD" in Git.
Discussions

git - How to branch from a previous commit - Stack Overflow
The checkout command with the parameter -b will create a new branch and it will switch you over to it. ... is it possible to create a branch based on the SHA commit of a feature branch that was deleted via a pull request? Or do I have to branch from the commit of the pull request on master? 2019-11-27T15:19:19.027Z+00:00 ... run git ... More on stackoverflow.com
🌐 stackoverflow.com
Is this the way to checkout a repo to a specific commit?
Sure, that works, and it creates a new branch called "bar", but you don't even need to make a branch. You can just git checkout if you only want to look at it. You can even commit changes, but you'll be working on a detached head. If you later want to turn that into a branch, you can. More on reddit.com
🌐 r/git
4
1
January 22, 2021
git filter-branch doesn't seem to remove files from old commits when I "git checkout xxxx"
When you git checkout xxxx, what is xxxx? If it's a commit hash this is expected behaviour. All "rewriting" commands actually create brand new commits. Sometimes they also move branch pointers around so old commits become unreachable. (That is, there is no ref that points to any commit whose ancestors include the unreachable commit.) But until those old commits are removed, e.g. via git gc, they can still be accessed if you have their IDs. Try checking out an affected branch instead. That should let you see the new commits. They'll look a lot like the old commits, but they'll have different hashes. More on reddit.com
🌐 r/git
8
4
September 19, 2018
Is there a straight-forward way to switch between git commits in VS Code?
There are plugins that accomplish this. I use Git Graph More on reddit.com
🌐 r/vscode
9
6
November 2, 2024
🌐
GitKraken
gitkraken.com › home › learn › git checkout
Git Checkout - Checkout Branches, Commits, & Tags | Learn Git
March 26, 2026 - Alternatively, you can use the GitKraken Fuzzy Finder by typing “checkout” followed by the branch name you want to checkout. GitKraken displays a list of your repository’s commits chronologically in the central graph. To Git checkout a commit in GitKraken, right-click on a commit from the central commit and select Checkout this commit.
🌐
Git
git-scm.com › docs › git-checkout
Git - git-checkout Documentation
... Branch to checkout; if it refers to a branch (i.e., a name that, when prepended with "refs/heads/", is a valid ref), then that branch is checked out. Otherwise, if it refers to a valid commit, your HEAD becomes "detached" and you are no longer on any branch (see below for details).
🌐
Atlassian
atlassian.com › git › tutorials › using branches › git checkout
Git Checkout | Atlassian Git Tutorial
Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch. Think of it as a way to select which line of development you’re working on.
Find elsewhere
🌐
Medium
medium.com › @Ariobarxan › checking-out-a-commit-in-git-533fe702cf23
Checking out a commit in Git. This article is one of the articles in… | by Ario Liyan | Medium
September 20, 2023 - However, it’s important to create a branch or switch to an existing branch if you want to preserve your work. To check out a specific commit in Git, you can use the git checkout command followed by the commit reference.
🌐
GitKraken
gitkraken.com › home › learn › problems & solutions › git checkout commit
How do you Git checkout a commit? | Solutions to Git Problems
November 30, 2022 - To checkout a previous commit, you will use the Git checkout command followed by the commit hash you retrieved from your Git log.
🌐
InMotion Hosting
inmotionhosting.com › inmotion hosting home › support › website › git › git checkout command – how to switch to branches and commits
Git Checkout Command - How To Switch To Branches and Commits | InMotion Hosting
February 20, 2025 - To checkout a commit, you can run a command similar to the following: ... You do not need to repeat the full commit hash, you can use the first 5-7 characters, and that should be enough. ... Note: switching to '3c05bb0'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch.
🌐
freeCodeCamp
freecodecamp.org › news › git-checkout-explained
Git Checkout Explained: How to Checkout, Change, or Switch a Branch in Git
December 31, 2019 - You have three options to handle your changes: 1) trash them, 2) commit them, or 3) stash them. To create and checkout out a new branch with a single command, you can use: ... This will automatically switch you to the new branch. The following command is similar to checking out a new branch, but uses the -B (note the captital B) flag and an optional START-POINT parameter: ... If the BRANCH-NAME branch doesn’t exist, Git will create it and start it at START-POINT.
🌐
GitHub
docs.github.com › en › desktop › managing-commits › checking-out-a-commit-in-github-desktop
Checking out a commit in GitHub Desktop - GitHub Docs
Right-click on the commit you would like to checkout and select Checkout commit. The Current Branch item in the repository bar will now show "Detached HEAD", along with the SHA of the commit that was checked out.
🌐
Linux Hint
linuxhint.com › checkout-specific-commit-git
How to Checkout a Specific Commit in Git? – Linux Hint
$ git checkout 8e2e9aa71ca94b74a9d9048841d95d408ff7db3b ... Once you have the checkout complete, you can perform all the changes in the repository and save it. ... NOTE: Checking out a specific commit creates a detached head. A detached head means that after checking out a commit, all the changes ...
🌐
Graphite
graphite.com › guides › checkout-file-from-prev-commit
Checking out files from previous Git commits - Graphite
This guide will walk you through various methods to checkout, revert, or reset a specific file to a previous commit's state in Git. git checkout: This command is used to switch branches or restore working tree files.
🌐
NoviceDev
novicedev.com › blog › create-git-branch-commit
How to Create a GIT Branch from a Commit? | NoviceDev
September 27, 2022 - GIT branch can be created with a commit hash using the ‘git checkout’ command with ‘-b’ option and then pass a new branch name with the commit SHA.
🌐
CoreUI
coreui.io › answers › how-to-checkout-a-commit-in-git
How to checkout a commit in Git · CoreUI
November 18, 2025 - The git checkout command with a commit hash puts your repository in “detached HEAD” state, allowing you to examine files and run tests without affecting any branch. You can use the full 40-character hash or a shortened version (typically ...
🌐
LabEx
labex.io › tutorials › git-how-to-checkout-specific-git-commit-462656
How to checkout specific git commit | LabEx
Git checkout is a powerful command that allows you to navigate between different commits, branches, and project states. ## Checkout a specific commit git checkout 7a5f91e ## Temporary detached HEAD state git checkout HEAD~3 ## Go back 3 commits · gitGraph commit id: "Initial Commit" commit id: "Add Feature A" commit id: "Add Feature B" commit id: "Bug Fix" ## Checkout specific file from another commit git checkout path/to/file < commit-hash > --
🌐
Graphite
graphite.com › guides › git-create-branch-from-commit
How to create a branch from a Git commit - Graphite
This command creates a new branch ... from the commit with the hash 9fceb02. If you want to switch to the new branch immediately, use: ... Engineers at Vercel, Snowflake & The Browser Company are shipping faster and staying unblocked with Graphite. ... If you wish to create a new branch but stay on your current branch, simply use the git branch command without the checkout...
🌐
DeployHQ
deployhq.com › learn git › commands › git checkout: switch branches, restore files & detached head
git checkout: Switch Branches, Restore Files & Detached HEAD - DeployHQ
September 2, 2019 - HEAD is now at 956951b Revert "Remove ... any branch. If you decide to keep your changes, create a new branch from here with git checkout -b my-fix....