🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 63 (from laksa002)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
1 hour ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.git-tower.com/learn/git/commands/git-checkout
Last Crawled2026-04-09 14:53:50 (1 hour ago)
First Indexed2019-06-29 03:15:22 (6 years ago)
HTTP Status Code200
Meta Titlegit checkout - Switching branches and restoring files | Learn Version Control with Git
Meta DescriptionLearn how to use the 'git checkout' command to switch the currently active branch, create a new branch, or restore files.
Meta Canonicalnull
Boilerpipe Text
The "checkout" command can switch the currently active branch - but it can also be used to restore files. The most common use case for "checkout" is when you want to switch to a different branch , making it the new HEAD branch. Another use case for "checkout" is when you want to restore a historic version of a specific file. Thereby, you can reset single files to earlier revisions - while keeping the rest of the project untouched. Important Options <branch-name> The name of a local branch that you want to switch to. By specifying the name of a local branch, you will switch to this branch and make it the current "HEAD" branch. -b <new-branch> Creates a new local branch and directly switches to it. This can be used as a shortcut instead of the following two commands: git branch &lt;new-branch-name&gt; git checkout &lt;new-branch-name&gt; . -b <new-branch> --track <remote-branch> Creates a new local branch - and sets up an "upstream" configuration. This way, the new local branch has a tracking relationship with its remote counterpart. This allows you to more easily see when the two aren't in sync (i.e. when unpushed commits in the local branch or unpulled commits in the remote exist). <file-path> <commit-hash> Restores a historic revision of a given file. By providing HEAD as the revision, you can restore the last committed version of a file - effectively undoing any local changes that happened since then. If you want to restore a specific earlier revision you can provide that revision's SHA-1 hash. -f / --force Forces the branch switch even if the working tree or index differs from HEAD. When switching branches, any local changes to tracked files are discarded. Important: -f does NOT delete untracked files. If an untracked file in your working directory would be overwritten by a file from the target branch, Git will still block the checkout — even with -f . To handle untracked files, use git clean -fd first, or git stash --include-untracked . -p / --patch Interactively select hunks to discard from the working tree. Instead of reverting an entire file, you can choose which individual changes to undo and which to keep. This is the inverse of git add -p : where add -p lets you selectively stage changes, checkout -p lets you selectively discard them. Usage Examples In its simplest (and most common) form, only the name of an existing local branch is specified: $ git checkout other-branch This will make the given branch the new HEAD branch. If, in one go, you also want to create a new local branch, you can use the "-b" parameter: $ git checkout -b new-branch By using the "--track" parameter, you can use a remote branch as the basis for a new local branch; this will also set up a "tracking relationship" between the two: $ git checkout -b new-branch --track origin/develop Another use case for "checkout" is when you want to restore an old revision of a file: $ git checkout 8a7b201 index.html If you specify "HEAD" as the revision, you will restore the last committed version of the file, effectively undoing any local changes that you current have in that file: $ git checkout HEAD index.html To discard all local changes in tracked files and restore them to the last committed state: $ git checkout . Or equivalently, using the explicit syntax with a double dash: $ git checkout -- . The double dash ( -- ) separates command options from file paths. This is useful to avoid ambiguity — for example, if you have a branch and a file with the same name: $ git checkout -- myfile.txt # restores the file $ git checkout myfile.txt # could mean file OR branch Note: git checkout . only affects tracked files. Untracked (new) files are not removed. Use git clean -fd to remove untracked files. Since Git 2.23, git restore . is the recommended command for discarding changes, as it avoids the overloaded nature of git checkout . To force a branch switch and discard any uncommitted changes to tracked files: $ git checkout -f main If untracked files conflict with files on the target branch, remove them first with git clean -fd or save them with git stash --include-untracked : $ git clean -fd && git checkout -f main To interactively select which changes to discard from a file: $ git checkout -p index.html Git will show each changed hunk and ask whether you want to discard it. This gives you fine-grained control over which changes to undo. Common confusion: git checkout -d There is no -d flag for git checkout . If you're looking to delete a branch, use git branch -d instead: $ git branch -d feature-branch # deletes the local branch $ git branch -D feature-branch # force-deletes (even if unmerged) Tip Quick Checkout in Tower In case you are using the Tower Git client , using checkout becomes easy as pie. Simply double-click a branch in the sidebar to make it the new HEAD branch - or choose a branch from a list. Learn More Check out the chapter Checking Out a Local Branch in our free online book Find the full command description in the Git documentation More frequently asked questions about Git & version control
Markdown
[Skip to main content](https://www.git-tower.com/learn/git/commands/git-checkout#main-content) [Tower](https://www.git-tower.com/) Navigation - [Features](https://www.git-tower.com/features) - [Undo Anything Just press Cmd+Z](https://www.git-tower.com/features/undo) - [Drag and Drop Make the complex effortless](https://www.git-tower.com/features/drag-and-drop) - [Integrations Use your favorite tools](https://www.git-tower.com/features/integrations) - [Tower Workflows Branching Configurations](https://www.git-tower.com/features/workflows) - [Stacked Pull Requests Supercharged workflows](https://www.git-tower.com/features/stacked-prs) - [All Features](https://www.git-tower.com/features/all-features) - [Release Notes](https://www.git-tower.com/release-notes) - [Pricing](https://www.git-tower.com/pricing) - [Support](https://www.git-tower.com/support) - [Documentation](https://www.git-tower.com/help) - [Contact Us](https://www.git-tower.com/support/contact) - [Account Login](https://account.git-tower.com/) - [Learn Git](https://www.git-tower.com/learn) - [Video Course 24 episodes](https://www.git-tower.com/learn/git/videos) - [Online Book From novice to master](https://www.git-tower.com/learn/git/ebook) - [Cheat Sheets For quick lookup](https://www.git-tower.com/learn/cheat-sheets) - [Webinar Learn from a Git professional](https://www.git-tower.com/learn/git/webinar) - [First Aid Kit Recover from mistakes](https://www.git-tower.com/learn/git/first-aid-kit) - [Advanced Git Kit Dive deeper](https://www.git-tower.com/learn/git/advanced-git-kit) - [Blog](https://www.git-tower.com/blog) - [Download](https://www.git-tower.com/download/mac) [Download](https://www.git-tower.com/download/windows) Git Commands An overview of the most important Git commands ![Git Commands featured image](https://www.git-tower.com/learn/assets/img/header-visuals/learners-questions.1773771024.svg) # git checkout **The "checkout" command can switch the currently active branch - but it can also be used to restore files.** The most common use case for "checkout" is when you want to *switch to a different branch*, making it the new HEAD branch. Another use case for "checkout" is when you want to *restore a historic version* of a specific file. Thereby, you can reset single files to earlier revisions - while keeping the rest of the project untouched. ## Important Options #### \<branch-name\> **The name of a local branch that you want to switch to.** By specifying the name of a local branch, you will switch to this branch and make it the current "HEAD" branch. #### \-b \<new-branch\> **Creates a new local branch and directly switches to it.** This can be used as a shortcut instead of the following two commands: `git branch &lt;new-branch-name&gt;` `git checkout &lt;new-branch-name&gt;`. #### \-b \<new-branch\> --track \<remote-branch\> **Creates a new local branch - and sets up an "upstream" configuration.** This way, the new local branch has a [tracking relationship](https://www.git-tower.com/learn/git/faq/track-remote-upstream-branch) with its remote counterpart. This allows you to more easily see when the two aren't in sync (i.e. when *unpushed* commits in the local branch or *unpulled* commits in the remote exist). #### \<file-path\> \<commit-hash\> **Restores a historic revision of a given file.** By providing HEAD as the revision, you can restore the last committed version of a file - effectively undoing any local changes that happened since then. If you want to restore a *specific* earlier revision you can provide that revision's SHA-1 hash. #### \-f / --force **Forces the branch switch even if the working tree or index differs from HEAD.** When switching branches, any local changes to tracked files are discarded. **Important:** `-f` does NOT delete untracked files. If an untracked file in your working directory would be overwritten by a file from the target branch, Git will still block the checkout — even with `-f`. To handle untracked files, use `git clean -fd` first, or `git stash --include-untracked`. #### \-p / --patch **Interactively select hunks to discard from the working tree.** Instead of reverting an entire file, you can choose which individual changes to undo and which to keep. This is the inverse of `git add -p`: where `add -p` lets you selectively stage changes, `checkout -p` lets you selectively discard them. ## Usage Examples In its simplest (and most common) form, only the name of an existing local branch is specified: ``` $ git checkout other-branch ``` This will make the given branch the new HEAD branch. If, in one go, you also want to create a new local branch, you can use the "-b" parameter: ``` $ git checkout -b new-branch ``` By using the "--track" parameter, you can use a *remote branch* as the basis for a new local branch; this will also set up a "tracking relationship" between the two: ``` $ git checkout -b new-branch --track origin/develop ``` Another use case for "checkout" is when you want to restore an old revision of a file: ``` $ git checkout 8a7b201 index.html ``` If you specify "HEAD" as the revision, you will restore the last committed version of the file, effectively undoing any local changes that you current have in that file: ``` $ git checkout HEAD index.html ``` To discard all local changes in tracked files and restore them to the last committed state: ``` $ git checkout . ``` Or equivalently, using the explicit syntax with a double dash: ``` $ git checkout -- . ``` The double dash (`--`) separates command options from file paths. This is useful to avoid ambiguity — for example, if you have a branch and a file with the same name: ``` $ git checkout -- myfile.txt # restores the file $ git checkout myfile.txt # could mean file OR branch ``` **Note:** `git checkout .` only affects tracked files. Untracked (new) files are not removed. Use `git clean -fd` to remove untracked files. Since Git 2.23, `git restore .` is the recommended command for discarding changes, as it avoids the overloaded nature of `git checkout`. To force a branch switch and discard any uncommitted changes to tracked files: ``` $ git checkout -f main ``` If untracked files conflict with files on the target branch, remove them first with `git clean -fd` or save them with `git stash --include-untracked`: ``` $ git clean -fd && git checkout -f main ``` To interactively select which changes to discard from a file: ``` $ git checkout -p index.html ``` Git will show each changed hunk and ask whether you want to discard it. This gives you fine-grained control over which changes to undo. **Common confusion: git checkout -d** There is no `-d` flag for `git checkout`. If you're looking to delete a branch, use `git branch -d` instead: ``` $ git branch -d feature-branch # deletes the local branch $ git branch -D feature-branch # force-deletes (even if unmerged) ``` ##### Tip #### Quick Checkout in Tower In case you are using the [Tower Git client](https://www.git-tower.com/?utm_source=learn-website&utm_campaign=git-commands&utm_medium=easy-in-tower&utm_content=git-checkout), using checkout becomes easy as pie. Simply double-click a branch in the sidebar to make it the new HEAD branch - or choose a branch from a list. ## Learn More - Check out the chapter [Checking Out a Local Branch](https://www.git-tower.com/learn/git/ebook/en/desktop-gui/branching-merging/checkout#start) in our free online book - Find the full command description in the [Git documentation](https://git-scm.com/docs/git-checkout) - More [frequently asked questions](https://www.git-tower.com/learn/git/faq) about Git & version control ## Get our popular **Git Cheat Sheet** for free\! You'll find the most important commands on the front and helpful best practice tips on the back. Over 100,000 developers have downloaded it to make Git a little bit easier. ![Get our popular Git Cheat Sheet for free\!](https://www.git-tower.com/learn/assets/img/popups/cheat-sheet-illu-huge.svg) ## About Us As the makers of [Tower, the best Git client for Mac and Windows](https://www.git-tower.com/?utm_source=learn-website&utm_medium=about-us&utm_campaign=learn-git), we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git. Just like with Tower, our mission with this platform is to help people become better professionals. That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free. [![Tower icon](https://www.git-tower.com/learn/assets/img/tower-icon.1773771024.svg)](https://www.git-tower.com/?utm_source=learn-website&utm_medium=about-us&utm_campaign=learn-git) About - [About](https://www.git-tower.com/company/about) - [Blog](https://www.git-tower.com/blog) - [Merch](https://stuff.git-tower.com/) - [Tower Git Client](https://www.git-tower.com/) Git & Version Control - [Online Book](https://www.git-tower.com/learn/git/ebook) - [First Aid Kit](https://www.git-tower.com/learn/git/first-aid-kit) - [Webinar](https://www.git-tower.com/learn/git/webinar) - [Video Course](https://www.git-tower.com/learn/git/videos) - [Advanced Git Kit](https://www.git-tower.com/learn/git/advanced-git-kit) - [FAQ](https://www.git-tower.com/learn/git/faq) - [Glossary](https://www.git-tower.com/learn/git/glossary) - [Commands](https://www.git-tower.com/learn/git/commands) Cheat Sheets - [Command Line 101](https://www.git-tower.com/learn/cheat-sheets/cli) - [Git](https://www.git-tower.com/learn/cheat-sheets/git) - [Git for Subversion Users](https://www.git-tower.com/learn/cheat-sheets/git-for-svn) - [HTML](https://www.git-tower.com/learn/cheat-sheets/html) - [Hugo](https://www.git-tower.com/learn/cheat-sheets/hugo) - [JavaScript](https://www.git-tower.com/learn/cheat-sheets/javascript) - [Markdown](https://www.git-tower.com/learn/cheat-sheets/markdown) - [PowerShell](https://www.git-tower.com/learn/cheat-sheets/powershell) - [Regex](https://www.git-tower.com/learn/cheat-sheets/regex) - [Ruby on Rails](https://www.git-tower.com/learn/cheat-sheets/ruby-on-rails) - [Tower Git Client](https://www.git-tower.com/learn/cheat-sheets/tower) - [Visual Studio Code](https://www.git-tower.com/learn/cheat-sheets/vscode) - [Website Optimization](https://www.git-tower.com/learn/cheat-sheets/website-optimization) - [Workflow of Version Control](https://www.git-tower.com/learn/cheat-sheets/vcs-workflow) - [Working with Branches in Git](https://www.git-tower.com/learn/cheat-sheets/git-branches) - [Xcode](https://www.git-tower.com/learn/cheat-sheets/xcode) ## Your trial is downloading… Try Tower "Pro" for 30 days without limitations\! ![Tower Icon](https://www.git-tower.com/learn/assets/img/icons/downloads-modal-app-icon.1773771024.png) Tower Close ## Updates, Courses & Content via Email ## Thank you for subscribing Please check your email to confirm Close ## Want to win one of our awesome Tower shirts? **Tell your friends about Tower\!** [Share on Twitter](https://www.git-tower.com/learn/git/commands/git-checkout) We'll pick 4 winners every month who share this tweet\! Follow [@gittower](https://x.com/gittower) to be notified if you win\! ## Try Tower for Free Sign up below and use Tower "Pro" for 30 days without limitations\! Close [Imprint / Legal Notice](https://www.git-tower.com/legal/imprint) \| [Privacy Policy](https://www.git-tower.com/legal/privacy-policy) \| Privacy Settings © 2010-2026 [Tower](https://www.git-tower.com/) - Mentioned product names and logos are property of their respective owners.
Readable Markdown
**The "checkout" command can switch the currently active branch - but it can also be used to restore files.** The most common use case for "checkout" is when you want to *switch to a different branch*, making it the new HEAD branch. Another use case for "checkout" is when you want to *restore a historic version* of a specific file. Thereby, you can reset single files to earlier revisions - while keeping the rest of the project untouched. ## Important Options #### \<branch-name\> **The name of a local branch that you want to switch to.** By specifying the name of a local branch, you will switch to this branch and make it the current "HEAD" branch. #### \-b \<new-branch\> **Creates a new local branch and directly switches to it.** This can be used as a shortcut instead of the following two commands: `git branch &lt;new-branch-name&gt;` `git checkout &lt;new-branch-name&gt;`. #### \-b \<new-branch\> --track \<remote-branch\> **Creates a new local branch - and sets up an "upstream" configuration.** This way, the new local branch has a [tracking relationship](https://www.git-tower.com/learn/git/faq/track-remote-upstream-branch) with its remote counterpart. This allows you to more easily see when the two aren't in sync (i.e. when *unpushed* commits in the local branch or *unpulled* commits in the remote exist). #### \<file-path\> \<commit-hash\> **Restores a historic revision of a given file.** By providing HEAD as the revision, you can restore the last committed version of a file - effectively undoing any local changes that happened since then. If you want to restore a *specific* earlier revision you can provide that revision's SHA-1 hash. #### \-f / --force **Forces the branch switch even if the working tree or index differs from HEAD.** When switching branches, any local changes to tracked files are discarded. **Important:** `-f` does NOT delete untracked files. If an untracked file in your working directory would be overwritten by a file from the target branch, Git will still block the checkout — even with `-f`. To handle untracked files, use `git clean -fd` first, or `git stash --include-untracked`. #### \-p / --patch **Interactively select hunks to discard from the working tree.** Instead of reverting an entire file, you can choose which individual changes to undo and which to keep. This is the inverse of `git add -p`: where `add -p` lets you selectively stage changes, `checkout -p` lets you selectively discard them. ## Usage Examples In its simplest (and most common) form, only the name of an existing local branch is specified: ``` $ git checkout other-branch ``` This will make the given branch the new HEAD branch. If, in one go, you also want to create a new local branch, you can use the "-b" parameter: ``` $ git checkout -b new-branch ``` By using the "--track" parameter, you can use a *remote branch* as the basis for a new local branch; this will also set up a "tracking relationship" between the two: ``` $ git checkout -b new-branch --track origin/develop ``` Another use case for "checkout" is when you want to restore an old revision of a file: ``` $ git checkout 8a7b201 index.html ``` If you specify "HEAD" as the revision, you will restore the last committed version of the file, effectively undoing any local changes that you current have in that file: ``` $ git checkout HEAD index.html ``` To discard all local changes in tracked files and restore them to the last committed state: ``` $ git checkout . ``` Or equivalently, using the explicit syntax with a double dash: ``` $ git checkout -- . ``` The double dash (`--`) separates command options from file paths. This is useful to avoid ambiguity — for example, if you have a branch and a file with the same name: ``` $ git checkout -- myfile.txt # restores the file $ git checkout myfile.txt # could mean file OR branch ``` **Note:** `git checkout .` only affects tracked files. Untracked (new) files are not removed. Use `git clean -fd` to remove untracked files. Since Git 2.23, `git restore .` is the recommended command for discarding changes, as it avoids the overloaded nature of `git checkout`. To force a branch switch and discard any uncommitted changes to tracked files: ``` $ git checkout -f main ``` If untracked files conflict with files on the target branch, remove them first with `git clean -fd` or save them with `git stash --include-untracked`: ``` $ git clean -fd && git checkout -f main ``` To interactively select which changes to discard from a file: ``` $ git checkout -p index.html ``` Git will show each changed hunk and ask whether you want to discard it. This gives you fine-grained control over which changes to undo. **Common confusion: git checkout -d** There is no `-d` flag for `git checkout`. If you're looking to delete a branch, use `git branch -d` instead: ``` $ git branch -d feature-branch # deletes the local branch $ git branch -D feature-branch # force-deletes (even if unmerged) ``` ##### Tip #### Quick Checkout in Tower In case you are using the [Tower Git client](https://www.git-tower.com/?utm_source=learn-website&utm_campaign=git-commands&utm_medium=easy-in-tower&utm_content=git-checkout), using checkout becomes easy as pie. Simply double-click a branch in the sidebar to make it the new HEAD branch - or choose a branch from a list. ## Learn More - Check out the chapter [Checking Out a Local Branch](https://www.git-tower.com/learn/git/ebook/en/desktop-gui/branching-merging/checkout#start) in our free online book - Find the full command description in the [Git documentation](https://git-scm.com/docs/git-checkout) - More [frequently asked questions](https://www.git-tower.com/learn/git/faq) about Git & version control
Shard63 (laksa)
Root Hash2236478454510524063
Unparsed URLcom,git-tower!www,/learn/git/commands/git-checkout s443