UPGRADE TO GET UP TO 85% OFF GITKRAKEN PRO
Search
Close this search box.

Git Checkout

The Git checkout command tells Git to which branch or commit you want your changes applied.

Now, before we get going on how to Git checkout in the GitKraken Git client and the command line, let’s first do a quick refresher on Git branch and Git commit.

In Git, a branch is a pointer to one specific commit, while a commit is a snapshot of your repository at a specific point in time.

Your branch pointer moves along with each new commit you make.

In GitKraken, you can quickly identify branches and related commits, making checkouts a breeze.

Git Checkout Branch

If you want to make changes to a branch that you don’t already have checked out, you will first need to checkout the branch.

GiTip: Learn how to Git checkout a remote branch and how to switch between local branches.

Checking out a Git branch will update your repository’s files to match the snapshot of whichever commit the branch points to. From here, the branch pointer will continue to follow each new commit made on the branch.

Git Checkout Commit

It is also possible to Git checkout a commit. This will update your repository’s files to match the snapshot of the commit you have checked out. This can be great for reviewing old commits without creating a new branch.

GitTip: If you want to learn more about how to Git checkout a commit, we can walk you through it.

Git Checkout Tag

Similarly, you can Git checkout a tag if you want to review a past version of your code, maybe from a recent release for example.

GitTip: Learn more about how to checkout a Git tag with GitKraken and the command line.

Git Detached HEAD

It’s important to be aware: checking out a Git commit or a Git tag will move the HEAD point to a commit instead of a branch. This will put your repository in what’s called detached HEAD state.

When you are in detached HEAD state in Git, you are not able to commit changes to a branch.

Benefits of Git Checkout

Git checkout is great for applying changes to branches, but it is also useful for reviewing old commits if you ever want to check when a certain behavior was introduced.

How do you Git checkout with GitKraken?

Whether you want to use the Git checkout command to checkout a branch, a commit, or tag, GitKraken makes the process easy and intuitive with complete visual context of your entire repository.

Tired of wasting time searching for commit hashes or tag names? GitKraken can help.

How do you Git checkout a branch with GitKraken?

In this example, we’re going to review how to use the Git checkout command to checkout a remote branch.

Thanks to the visual benefits offered by GitKraken’s main user interface, you can view all of your remote branches listed on the left panel.

To Git checkout a remote branch in GitKraken, simply double-click or right-click the branch name from the left panel or central graph and select Checkout.

Alternatively, you can use the GitKraken Fuzzy Finder by typing “checkout” followed by the branch name you want to checkout.

How do you Git checkout a commit with GitKraken?

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.

How do you Git checkout a tag with GitKraken?

In GitKraken, tags are marked in the central graph with a 🏷 tag icon. This makes it quick and easy to locate your repo’s tags.

From the central graph, locate the tag you wish to checkout and right-click. Then, select Checkout this commit to checkout the tag in a detached HEAD state.

But, what if you wanted to checkout the tag as a branch? You can follow the exact same process, but select Create branch here after right-clicking the target tag from the central graph or left panel.

In just 2 clicks, you can checkout a branch, commit, or tag in GitKraken. 🤯

How do you Git checkout a branch in the command line?

If you’re using the CLI, you won’t have immediate visibility into your local branches, so you will start by running the Git branch command to view a list of your local branches. This will also show you which branch you currently have checked out.

Next, you will run the Git checkout command followed by the name of the local branch you wish to switch over to.

git checkout <name-of-branch>

How do you Git checkout a commit in the command line?

In order to Git checkout a commit in the CLI, you’re going to need the commit hash. You can obtain your commit hash by running the Git log command.

To checkout the previous commit, you will use the Git checkout command followed by the commit hash.

git checkout <commit hash>

How do you Git checkout a tag in the command line?

Unlike in GitKraken, where you can easily locate your tags by looking for the tag icon in your central graph, you will have to run the Git tag command to view a list of your repository’s tags.

After you have your tag name, you can checkout the tag in a Git detached HEAD state, or checkout the tag as a branch. If you want to checkout the tag in a detached HEAD state, you will run:

git checkout <tag name>

If you want to Git checkout the tag as a branch, you will run:

git checkout -b <branch name> <tag name>

Your time and mental energy are valuable; why spend them trying to remember or having to look up remote branches, commit hashes, or tag names? Let the legendary cross-platform GitKraken Git GUI organize all of that for you, and present your repository in a beautiful, and easy to follow, graph.

Additional Resources

Table of Contents

Make Git Easier, Safer &
More Powerful

with GitKraken

Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.

Team Collaboration Services

Secure cloud-backed services that span across all products in the DevEx platform to keep your workflows connected across projects, repos, and team members
Launchpad – All your PRs, issues, & tasks in one spot to kick off a focused, unblocked day. Code Suggest – Real code suggestions anywhere in your project, as simple as in Google Docs. Cloud Patches – Speed up PR reviews by enabling early collaboration on work-in-progress. Workspaces – Group & sync repos to simplify multi-repo actions, & get new devs coding faster. DORA Insights – Data-driven code insights to track & improve development velocity. Security & Admin – Easily set up SSO, manage access, & streamline IdP integrations.
winget install gitkraken.cli