Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
-
2.55.0
2026-06-29
-
2.54.0
2026-04-20
-
2.53.0
2026-02-02
-
2.52.0
2025-11-17
- 2.51.1 → 2.51.2 no changes
-
2.51.0
2025-08-18
- 2.50.1 no changes
-
2.50.0
2025-06-16
- 2.47.2 → 2.49.1 no changes
-
2.47.1
2024-11-25
- 2.44.1 → 2.47.0 no changes
-
2.44.0
2024-02-23
- 2.43.2 → 2.43.7 no changes
-
2.43.1
2024-02-09
-
2.43.0
2023-11-20
- 2.41.1 → 2.42.4 no changes
-
2.41.0
2023-06-01
- 2.40.1 → 2.40.4 no changes
-
2.40.0
2023-03-12
- 2.39.4 → 2.39.5 no changes
-
2.39.3
2023-04-17
- 2.38.1 → 2.39.2 no changes
-
2.38.0
2022-10-02
- 2.35.1 → 2.37.7 no changes
-
2.35.0
2022-01-24
- 2.34.1 → 2.34.8 no changes
-
2.34.0
2021-11-15
- 2.30.1 → 2.33.8 no changes
-
2.30.0
2020-12-27
- 2.29.1 → 2.29.3 no changes
-
2.29.0
2020-10-19
- 2.27.1 → 2.28.1 no changes
-
2.27.0
2020-06-01
- 2.25.1 → 2.26.3 no changes
-
2.25.0
2020-01-13
- 2.23.1 → 2.24.4 no changes
-
2.23.0
2019-08-16
- 2.22.1 → 2.22.5 no changes
-
2.22.0
2019-06-07
- 2.21.1 → 2.21.4 no changes
-
2.21.0
2019-02-24
- 2.19.3 → 2.20.5 no changes
-
2.19.2
2018-11-21
- 2.19.1 no changes
-
2.19.0
2018-09-10
- 2.17.0 → 2.18.5 no changes
-
2.16.6
2019-12-06
- 2.15.4 no changes
-
2.14.6
2019-12-06
-
2.13.7
2018-05-22
- 2.11.4 → 2.12.5 no changes
-
2.10.5
2017-09-22
-
2.9.5
2017-07-30
- 2.8.6 no changes
-
2.7.6
2017-07-30
- 2.6.7 no changes
-
2.5.6
2017-05-05
-
2.4.12
2017-05-05
- 2.1.4 → 2.3.10 no changes
-
2.0.5
2014-12-17
SYNOPSIS
git checkout [-q] [-f] [-m] [<branch>] git checkout [-q] [-f] [-m] --detach [<branch>] git checkout [-q] [-f] [-m] [--detach] <commit> git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>] git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>… git checkout [<tree-ish>] [--] <pathspec>… git checkout (-p|--patch) [<tree-ish>] [--] [<paths>…]
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.
- git checkout <branch>
-
To prepare for working on <branch>, switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.
If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to
$ git checkout -b <branch> --track <remote>/<branch>
If the branch exists in multiple remotes and one of them is named by the
checkout.defaultRemoteconfiguration variable, we’ll use that one for the purposes of disambiguation, even if the <branch> isn’t unique across all remotes. Set it to e.g.checkout.defaultRemote=originto always checkout remote branches from there if <branch> is ambiguous but exists on the origin remote. See alsocheckout.defaultRemotein git-config[1].You could omit <branch>, in which case the command degenerates to "check out the current branch", which is a glorified no-op with rather expensive side-effects to show only the tracking information, if exists, for the current branch.
- git checkout -b|-B <new_branch> [<start point>]
-
Specifying
-bcauses a new branch to be created as if git-branch[1] were called and then checked out. In this case you can use the--trackor--no-trackoptions, which will be passed to git branch. As a convenience,--trackwithout-bimplies branch creation; see the description of--trackbelow.If
-Bis given, <new_branch> is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of$ git branch -f <branch> [<start point>] $ git checkout <branch>
that is to say, the branch is not reset/created unless "git checkout" is successful.
- git checkout --detach [<branch>]
- git checkout [--detach] <commit>
-
Prepare to work on top of <commit>, by detaching HEAD at it (see "DETACHED HEAD" section), and updating the index and the files in the working tree. Local modifications to the files in the working tree are kept, so that the resulting working tree will be the state recorded in the commit plus the local modifications.
When the <commit> argument is a branch name, the
--detachoption can be used to detach HEAD at the tip of the branch (gitcheckout<branch> would check out that branch without detaching HEAD).Omitting <branch> detaches HEAD at the tip of the current branch.
- git checkout [