🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 44 (from laksa143)

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
8 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.3 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.atlassian.com/git/tutorials/resetting-checking-out-and-reverting
Last Crawled2026-04-01 03:57:05 (8 days ago)
First Indexed2014-09-20 14:45:30 (11 years ago)
HTTP Status Code200
Meta TitleResetting, Checking Out & Reverting | Atlassian Git Tutorial
Meta DescriptionThe git checkout command is used to update the repository state to a specific point in projects history. Learn the different ways to undo changes in Git.
Meta Canonicalnull
Boilerpipe Text
The git reset , git checkout , and git revert commands are some of the most useful tools in your Git toolbox. They all let you undo some kind of change in your repository, and the first two commands can be used to manipulate either commits or individual files. Because they’re so similar, it’s very easy to mix up which command should be used in any given development scenario. In this article, we’ll compare the most common configurations of git reset , git checkout , and git revert . Hopefully, you’ll walk away with the confidence to navigate your repository using any of these commands. It helps to think about each command in terms of their effect on the three state management mechanisms of a Git repository: the working directory, the staged snapshot, and the commit history. These components are sometimes known as "The three trees" of Git. We explore the three trees in depth on the git reset page. Keep these mechanisms in mind as you read through this article. A checkout is an operation that moves the HEAD ref pointer to a specified commit. To demonstrate this consider the following example. This example demonstrates a sequence of commits on the main  branch. The HEAD ref and main  branch ref currently point to commit d. Now let us execute  git checkout b This is an update to the "Commit History" tree. The git checkout command can be used in a commit, or file level scope. A file level checkout will change the file's contents to those of the specific commit. A revert is an operation that takes a specified commit and creates a new commit which inverses the specified commit. git revert can only be run at a commit level scope and has no file level functionality. A reset is an operation that takes a specified commit and resets the "three trees" to match the state of the repository at that specified commit. A reset can be invoked in three different modes which correspond to the three trees. Checkout and reset are generally used for making local or private 'undos'. They modify the history of a repository that can cause conflicts when pushing to remote shared repositories. Revert is considered a safe operation for 'public undos' as it creates new history which can be shared remotely and doesn't overwrite history remote team members may be dependent on. Git reset vs revert vs checkout reference The table below sums up the most common use cases for all of these commands. Be sure to keep this reference handy, as you’ll undoubtedly need to use at least some of them during your Git career. Command Scope Common use cases git reset Commit-level Discard commits in a private branch or throw away uncommitted changes git reset File-level Unstage a file git checkout Commit-level Switch between branches or inspect old snapshots git checkout File-level Discard changes in the working directory git revert Commit-level Undo commits in a public branch git revert File-level (N/A) Commit level operations The parameters that you pass to git reset and git checkout determine their scope. When you don’t include a file path as a parameter, they operate on whole commits. That’s what we’ll be exploring in this section. Note that git revert has no file-level counterpart. Reset a specific commit On the commit-level, resetting is a way to move the tip of a branch to a different commit. This can be used to remove commits from the current branch. For example, the following command moves the hotfix branch backwards by two commits. git checkout hotfix git reset HEAD~2 The two commits that were on the end of hotfix are now dangling, or orphaned commits. This means they will be deleted the next time Git performs a garbage collection. In other words, you’re saying that you want to throw away these commits. This can be visualized as the following: This usage of git reset is a simple way to undo changes that haven’t been shared with anyone else. It’s your go-to command when you’ve started working on a feature and find yourself thinking, “Oh crap, what am I doing? I should just start over.” In addition to moving the current branch, you can also get git reset to alter the staged snapshot and/or the working directory by passing it one of the following flags: --soft – The staged snapshot and working directory are not altered in any way. --mixed – The staged snapshot is updated to match the specified commit, but the working directory is not affected. This is the default option. --hard – The staged snapshot and the working directory are both updated to match the specified commit. It’s easier to think of these modes as defining the scope of a git reset operation. For further detailed information visit the git reset page. Checkout old commits The git checkout command is used to update the state of the repository to a specific point in the projects history. When passed with a branch name, it lets you switch between branches. git checkout hotfix Internally, all the above command does is move HEAD to a different branch and update the working directory to match. Since this has the potential to overwrite local changes, Git forces you to commit or stash any changes in the working directory that will be lost during the checkout operation. Unlike git reset , git checkout doesn’t move any branches around. You can also check out arbitrary commits by passing the commit reference instead of a branch. This does the exact same thing as checking out a branch: it moves the HEAD reference to the specified commit. For example, the following command will check out the grandparent of the current commit: git checkout HEAD~2 This is useful for quickly inspecting an old version of your project. However, since there is no branch reference to the current HEAD , this puts you in a detached HEAD state. This can be dangerous if you start adding new commits because there will be no way to get back to them after you switch to another branch. For this reason, you should always create a new branch before adding commits to a detached HEAD . Undo public commits with revert Reverting undoes a commit by creating a new commit. This is a safe way to undo changes, as it has no chance of re-writing the commit history. For example, the following command will figure out the changes contained in the 2nd to last commit, create a new commit undoing those changes, and tack the new commit onto the existing project. git checkout hotfix git revert HEAD~2 This can be visualized as the following: Contrast this with git reset , which does alter the existing commit history. For this reason, git revert should be used to undo changes on a public branch, and git reset should be reserved for undoing changes on a private branch. You can also think of git revert as a tool for undoing committed changes, while git reset HEAD is for undoing uncommitted changes. Like git checkout , git revert has the potential to overwrite files in the working directory, so it will ask you to commit or stash changes that would be lost during the revert operation. File-level operations The git reset and git checkout commands also accept an optional file path as a parameter. This dramatically alters their behavior. Instead of operating on entire snapshots, this forces them to limit their operations to a single file. Git reset a specific file When invoked with a file path, git reset updates the staged snapshot to match the version from the specified commit. For example, this command will fetch the version of foo.py in the 2nd-to-last commit and stage it for the next commit: git reset HEAD~2 foo.py As with the commit-level version of git reset , this is more commonly used with HEAD rather than an arbitrary commit. Running git reset HEAD foo.py will unstage foo.py . The changes it contains will still be present in the working directory. The --soft , --mixed , and --hard flags do not have any effect on the file-level version of git reset , as the staged snapshot is always updated, and the working directory is never updated. Git checkout file Checking out a file is similar to using git reset with a file path, except it updates the working directory instead of the stage. Unlike the commit-level version of this command, this does not move the HEAD reference, which means that you won’t switch branches. For example, the following command makes foo.py in the working directory match the one from the 2nd-to-last commit: git checkout HEAD~2 foo.py Just like the commit-level invocation of git checkout , this can be used to inspect old versions of a project—but the scope is limited to the specified file. If you stage and commit the checked-out file, this has the effect of “reverting” to the old version of that file. Note that this removes all of the subsequent changes to the file, whereas the git revert command undoes only the changes introduced by the specified commit. Like git reset , this is commonly used with HEAD as the commit reference. For instance, git checkout HEAD foo.py has the effect of discarding unstaged changes to foo.py . This is similar behavior to git reset HEAD --hard , but it operates only on the specified file. Summary You should now have all the tools you could ever need to undo changes in a Git repository. The git reset , git checkout , and git revert commands can be confusing, but when you think about their effects on the working directory, staged snapshot, and commit history, it should be easier to discern which command fits the development task at hand.
Markdown
[Skip to content](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting#content) - [Products](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting) Featured Developers Product Managers IT professionals Business Teams Leadership Teams [See all apps](https://www.atlassian.com/software) - ## Featured apps - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Confluence** Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [**Jira Service Management** Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) ## Atlassian Collections - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) - [Optimize strategy and outcomes confidently FocusTalentAlign](https://www.atlassian.com/collections/strategy) - [Deliver service at high-velocity Jira Service ManagementCustomer Service ManagementAssets](https://www.atlassian.com/collections/service) - [Ship high-quality software fast Rovo DevDXPipelinesBitbucketCompass](https://www.atlassian.com/collections/software) Powered by [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Bitbucket** Source code and CI/CD](https://www.atlassian.com/software/bitbucket) - [**Rovo Dev** Agentic AI for developers](https://www.atlassian.com/software/rovo-dev) - [**Pipelines** Scalable CI/CD automation](https://www.atlassian.com/software/bitbucket/features/pipelines) - [**DX** Measure productivity and AI impact](https://www.atlassian.com/collections/software) - [**Compass** Software catalog for teams](https://www.atlassian.com/software/compass) - [Ship high-quality software fast Rovo DevDXPipelinesBitbucketCompass](https://www.atlassian.com/collections/software) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) - [**Jira Product Discovery** Capture & prioritize ideas](https://www.atlassian.com/software/jira/product-discovery) - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Confluence** Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) - [**Jira Service Management** Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) - [**Guard** Enhanced cloud security](https://www.atlassian.com/software/guard) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Confluence** Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [**Trello** Capture and organize your tasks](https://trello.com/home) - [**Loom** Quick, async video updates](https://www.atlassian.com/software/loom) - [**Jira Service Management** Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) - [**Customer Service Management** Customer experiences reimagined](https://www.atlassian.com/software/customer-service-management) - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) - [**Focus** Enterprise-scale strategic planning](https://www.atlassian.com/software/focus) - [**Talent** Knowledge workforce planning](https://www.atlassian.com/software/talent) - [**Align** Enterprise-wide work planning & value](https://www.atlassian.com/software/jira/align) - [Optimize strategy and outcomes confidently FocusTalentAlign](https://www.atlassian.com/collections/strategy) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) - [Solutions](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting) Solutions ## By Use Case - [Team collaboration](https://www.atlassian.com/collections/teamwork) - [Strategy and planning](https://www.atlassian.com/collections/strategy) - [Service management](https://www.atlassian.com/collections/service) - [Software development](https://www.atlassian.com/collections/software) ## By Team - [Software](https://www.atlassian.com/collections/software) - [Marketing](https://www.atlassian.com/teams/marketing) - [IT](https://www.atlassian.com/teams/it) - [Product](https://www.atlassian.com/software/jira/product-discovery%20) ## By Size - [Enterprise](https://www.atlassian.com/enterprise) - [Small Business](https://www.atlassian.com/software/small-business) - [Startup](https://www.atlassian.com/software/startups) - [Non-profit](https://www.atlassian.com/teams/nonprofits) ## By Industry - [Retail](https://www.atlassian.com/industries/retail) - [Telecommunications](https://www.atlassian.com/industries/telecom) - [Professional Services](https://www.atlassian.com/industries/professional-services) - [Government](https://www.atlassian.com/government) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) - [Why Atlassian?](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting) - [System of Work NewAtlassian's blueprint for how teams work together](https://www.atlassian.com/system-of-work) - [MarketplaceConnect thousands of apps to your Atlassian products](https://marketplace.atlassian.com/) - [CustomersCase studies & stories powered by teamwork](https://www.atlassian.com/customers) - [FedRAMPCompliant solutions for the public sector](https://www.atlassian.com/trust/compliance/resources/fedramp) - [ResilienceEnterprise-grade & highly performant infrastructure](https://www.atlassian.com/trust/resilience) - [PlatformOur deeply integrated, reliable & secure platform](https://www.atlassian.com/platform) - [Trust centerEnsure your data's security, compliance & availability](https://www.atlassian.com/trust) - [Resources](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting) - [Customer SupportAsk questions, report bugs & give us feedback](https://support.atlassian.com/) - [Find PartnersConsulting, training & product customization support](https://partnerdirectory.atlassian.com/) - [Atlassian AscendResources and support for your transformation](https://www.atlassian.com/migration) - [CommunityLearn, connect and grow with the Atlassian Community](https://community.atlassian.com/) ## Support ## Resources - [Enterprise](https://www.atlassian.com/enterprise) - More + Get it free Sign in Sign in - Products - Featured - Developers - Product Managers - IT professionals - Business Teams - Leadership Teams - Solutions - Why Atlassian? - Resources - [Enterprise](https://www.atlassian.com/enterprise) [Sign in](https://id.atlassian.com/login?continue=https%3A%2F%2Fwww.atlassian.com%2Fgateway%2Fapi%2Fstart%2Fauthredirect) - ## Featured apps - [Jira Flexible project management](https://www.atlassian.com/software/jira) - [Confluence Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [Jira Service Management Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) ## Atlassian Collections - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) - [Optimize strategy and outcomes confidently FocusTalentAlign](https://www.atlassian.com/collections/strategy) - [Deliver service at high-velocity Jira Service ManagementCustomer Service ManagementAssets](https://www.atlassian.com/collections/service) - [Ship high-quality software fast Rovo DevDXPipelinesBitbucketCompass](https://www.atlassian.com/collections/software) Powered by [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Developers - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Bitbucket** Source code and CI/CD](https://www.atlassian.com/software/bitbucket) - [**Rovo Dev** Agentic AI for developers](https://www.atlassian.com/software/rovo-dev) - [**Pipelines** Scalable CI/CD automation](https://www.atlassian.com/software/bitbucket/features/pipelines) - [**DX** Measure productivity and AI impact](https://www.atlassian.com/collections/software) - [**Compass** Software catalog for teams](https://www.atlassian.com/software/compass) - [Ship high-quality software fast Rovo DevDXPipelinesBitbucketCompass](https://www.atlassian.com/collections/software) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Product Managers - [**Jira Product Discovery** Capture & prioritize ideas](https://www.atlassian.com/software/jira/product-discovery) - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Confluence** Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) IT professionals - [**Jira Service Management** Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) - [**Guard** Enhanced cloud security](https://www.atlassian.com/software/guard) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Business Teams - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Confluence** Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [**Trello** Capture and organize your tasks](https://trello.com/home) - [**Loom** Quick, async video updates](https://www.atlassian.com/software/loom) - [**Jira Service Management** Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) - [**Customer Service Management** Customer experiences reimagined](https://www.atlassian.com/software/customer-service-management) - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Leadership Teams - [**Focus** Enterprise-scale strategic planning](https://www.atlassian.com/software/focus) - [**Talent** Knowledge workforce planning](https://www.atlassian.com/software/talent) - [**Align** Enterprise-wide work planning & value](https://www.atlassian.com/software/jira/align) - [Optimize strategy and outcomes confidently FocusTalentAlign](https://www.atlassian.com/collections/strategy) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Solutions ## By Use Case - [Team collaboration](https://www.atlassian.com/collections/teamwork) - [Strategy and planning](https://www.atlassian.com/collections/strategy) - [Service management](https://www.atlassian.com/collections/service) - [Software development](https://www.atlassian.com/collections/software) ## By Team - [Software](https://www.atlassian.com/collections/software) - [Marketing](https://www.atlassian.com/teams/marketing) - [IT](https://www.atlassian.com/teams/it) - [Product](https://www.atlassian.com/software/jira/product-discovery%20) ## By Size - [Enterprise](https://www.atlassian.com/enterprise) - [Small Business](https://www.atlassian.com/software/small-business) - [Startup](https://www.atlassian.com/software/startups) - [Non-profit](https://www.atlassian.com/teams/nonprofits) ## By Industry - [Retail](https://www.atlassian.com/industries/retail) - [Telecommunications](https://www.atlassian.com/industries/telecom) - [Professional Services](https://www.atlassian.com/industries/professional-services) - [Government](https://www.atlassian.com/government) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Why Atlassian [System of Work NewAtlassian's blueprint for how teams work together](https://www.atlassian.com/system-of-work) [MarketplaceConnect thousands of apps to your Atlassian products](https://marketplace.atlassian.com/) [CustomersCase studies & stories powered by teamwork](https://www.atlassian.com/customers) [FedRAMPCompliant solutions for the public sector](https://www.atlassian.com/trust/compliance/resources/fedramp) [ResilienceEnterprise-grade & highly performant infrastructure](https://www.atlassian.com/trust/resilience) [PlatformOur deeply integrated, reliable & secure platform](https://www.atlassian.com/platform) [Trust centerEnsure your data's security, compliance & availability](https://www.atlassian.com/trust) Resources [Customer SupportAsk questions, report bugs & give us feedback](https://support.atlassian.com/) [Find PartnersConsulting, training & product customization support](https://partnerdirectory.atlassian.com/) [Atlassian AscendResources and support for your transformation](https://www.atlassian.com/migration) [CommunityLearn, connect and grow with the Atlassian Community](https://community.atlassian.com/) Support - [General Inquiries](https://www.atlassian.com/company/contact/general-inquiries) - [Technical Support](https://support.atlassian.com/contact/) - [Product Advice](https://www.atlassian.com/company/contact/product-evaluator-advice) - [Pricing and Billing](https://www.atlassian.com/company/contact/purchasing-licensing) - [Partner Support](https://www.atlassian.com/partners) - [Developer Support](https://developer.atlassian.com/) - [Enterprise Support](https://www.atlassian.com/enterprise/services) - [Purchasing and Licensing](https://www.atlassian.com/licensing/purchase-licensing) Resources - [Project Management](https://www.atlassian.com/project-management) - [Project Collaboration](https://www.atlassian.com/work-management/project-collaboration) - [Agile](https://www.atlassian.com/agile) - [Team Playbook](https://www.atlassian.com/team-playbook) - [Atlassian Learning](https://community.atlassian.com/learning) - [Product Documentation](https://confluence.atlassian.com/display/ALLDOC/Atlassian+Documentation) - [Get Started](https://www.atlassian.com/get-started) [Skip to content](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting#content) - Products - Featured - Developers - Product Managers - IT professionals - Business Teams - Leadership Teams - Solutions - Why Atlassian? - Resources - [Enterprise](https://www.atlassian.com/enterprise) [Sign in](https://id.atlassian.com/login?continue=https%3A%2F%2Fwww.atlassian.com%2Fgateway%2Fapi%2Fstart%2Fauthredirect) - ## Featured apps - [Jira Flexible project management](https://www.atlassian.com/software/jira) - [Confluence Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [Jira Service Management Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) ## Atlassian Collections - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) - [Optimize strategy and outcomes confidently FocusTalentAlign](https://www.atlassian.com/collections/strategy) - [Deliver service at high-velocity Jira Service ManagementCustomer Service ManagementAssets](https://www.atlassian.com/collections/service) - [Ship high-quality software fast Rovo DevDXPipelinesBitbucketCompass](https://www.atlassian.com/collections/software) Powered by [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Developers - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Bitbucket** Source code and CI/CD](https://www.atlassian.com/software/bitbucket) - [**Rovo Dev** Agentic AI for developers](https://www.atlassian.com/software/rovo-dev) - [**Pipelines** Scalable CI/CD automation](https://www.atlassian.com/software/bitbucket/features/pipelines) - [**DX** Measure productivity and AI impact](https://www.atlassian.com/collections/software) - [**Compass** Software catalog for teams](https://www.atlassian.com/software/compass) - [Ship high-quality software fast Rovo DevDXPipelinesBitbucketCompass](https://www.atlassian.com/collections/software) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Product Managers - [**Jira Product Discovery** Capture & prioritize ideas](https://www.atlassian.com/software/jira/product-discovery) - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Confluence** Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) IT professionals - [**Jira Service Management** Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) - [**Guard** Enhanced cloud security](https://www.atlassian.com/software/guard) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Business Teams - [**Jira** Flexible project management](https://www.atlassian.com/software/jira) - [**Confluence** Knowledge, all in one place](https://www.atlassian.com/software/confluence) - [**Trello** Capture and organize your tasks](https://trello.com/home) - [**Loom** Quick, async video updates](https://www.atlassian.com/software/loom) - [**Jira Service Management** Deliver service at high velocity](https://www.atlassian.com/software/jira/service-management) - [**Customer Service Management** Customer experiences reimagined](https://www.atlassian.com/software/customer-service-management) - [Supercharge teamwork seamlessly JiraConfluenceLoom](https://www.atlassian.com/collections/teamwork) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Leadership Teams - [**Focus** Enterprise-scale strategic planning](https://www.atlassian.com/software/focus) - [**Talent** Knowledge workforce planning](https://www.atlassian.com/software/talent) - [**Align** Enterprise-wide work planning & value](https://www.atlassian.com/software/jira/align) - [Optimize strategy and outcomes confidently FocusTalentAlign](https://www.atlassian.com/collections/strategy) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Solutions ## By Use Case - [Team collaboration](https://www.atlassian.com/collections/teamwork) - [Strategy and planning](https://www.atlassian.com/collections/strategy) - [Service management](https://www.atlassian.com/collections/service) - [Software development](https://www.atlassian.com/collections/software) ## By Team - [Software](https://www.atlassian.com/collections/software) - [Marketing](https://www.atlassian.com/teams/marketing) - [IT](https://www.atlassian.com/teams/it) - [Product](https://www.atlassian.com/software/jira/product-discovery%20) ## By Size - [Enterprise](https://www.atlassian.com/enterprise) - [Small Business](https://www.atlassian.com/software/small-business) - [Startup](https://www.atlassian.com/software/startups) - [Non-profit](https://www.atlassian.com/teams/nonprofits) ## By Industry - [Retail](https://www.atlassian.com/industries/retail) - [Telecommunications](https://www.atlassian.com/industries/telecom) - [Professional Services](https://www.atlassian.com/industries/professional-services) - [Government](https://www.atlassian.com/government) [Rovo AI-powered apps – driven by your team's knowledge.](https://www.atlassian.com/software/rovo) Why Atlassian [System of Work NewAtlassian's blueprint for how teams work together](https://www.atlassian.com/system-of-work) [MarketplaceConnect thousands of apps to your Atlassian products](https://marketplace.atlassian.com/) [CustomersCase studies & stories powered by teamwork](https://www.atlassian.com/customers) [FedRAMPCompliant solutions for the public sector](https://www.atlassian.com/trust/compliance/resources/fedramp) [ResilienceEnterprise-grade & highly performant infrastructure](https://www.atlassian.com/trust/resilience) [PlatformOur deeply integrated, reliable & secure platform](https://www.atlassian.com/platform) [Trust centerEnsure your data's security, compliance & availability](https://www.atlassian.com/trust) Resources [Customer SupportAsk questions, report bugs & give us feedback](https://support.atlassian.com/) [Find PartnersConsulting, training & product customization support](https://partnerdirectory.atlassian.com/) [Atlassian AscendResources and support for your transformation](https://www.atlassian.com/migration) [CommunityLearn, connect and grow with the Atlassian Community](https://community.atlassian.com/) Support - [General Inquiries](https://www.atlassian.com/company/contact/general-inquiries) - [Technical Support](https://support.atlassian.com/contact/) - [Product Advice](https://www.atlassian.com/company/contact/product-evaluator-advice) - [Pricing and Billing](https://www.atlassian.com/company/contact/purchasing-licensing) - [Partner Support](https://www.atlassian.com/partners) - [Developer Support](https://developer.atlassian.com/) - [Enterprise Support](https://www.atlassian.com/enterprise/services) - [Purchasing and Licensing](https://www.atlassian.com/licensing/purchase-licensing) Resources - [Project Management](https://www.atlassian.com/project-management) - [Project Collaboration](https://www.atlassian.com/work-management/project-collaboration) - [Agile](https://www.atlassian.com/agile) - [Team Playbook](https://www.atlassian.com/team-playbook) - [Atlassian Learning](https://community.atlassian.com/learning) - [Product Documentation](https://confluence.atlassian.com/display/ALLDOC/Atlassian+Documentation) - [Get Started](https://www.atlassian.com/get-started) Git topics - Learn Git - [Git commands](https://www.atlassian.com/git/glossary) - [Learn Git with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud) - [Learn about code review in Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-about-code-review-in-bitbucket-cloud) - [Learn Branching with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-branching-with-bitbucket-cloud) - [Learn Undoing Changes with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-undoing-changes-with-bitbucket) - Beginner - [What is version control](https://www.atlassian.com/git/tutorials/what-is-version-control) - [Source Code Management](https://www.atlassian.com/git/tutorials/source-code-management) - [What is Git](https://www.atlassian.com/git/tutorials/what-is-git) - [Why Git for your organization](https://www.atlassian.com/git/tutorials/why-git) - [Install Git](https://www.atlassian.com/git/tutorials/install-git) - [Git SSH](https://www.atlassian.com/git/tutorials/git-ssh) - [Git archive](https://www.atlassian.com/git/tutorials/export-git-archive) - [GitOps](https://www.atlassian.com/git/tutorials/gitops) - [Git cheat sheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) - Getting started - Setting up a repository - [Overview](https://www.atlassian.com/git/tutorials/setting-up-a-repository) - [git init](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init) - [git clone](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone) - [git config](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config) - [git alias](https://www.atlassian.com/git/tutorials/git-alias) - Saving changes (Git add) - [Overview](https://www.atlassian.com/git/tutorials/saving-changes) - [git commit](https://www.atlassian.com/git/tutorials/saving-changes/git-commit) - [git diff](https://www.atlassian.com/git/tutorials/saving-changes/git-diff) - [git stash](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) - [.gitignore](https://www.atlassian.com/git/tutorials/saving-changes/gitignore) - Inspecting a repository - [Overview](https://www.atlassian.com/git/tutorials/inspecting-a-repository) - [git tag](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-tag) - [git blame](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-blame) - Undoing changes - [Overview](https://www.atlassian.com/git/tutorials/undoing-changes) - [git clean](https://www.atlassian.com/git/tutorials/undoing-changes/git-clean) - [git revert](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert) - [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset) - [git rm](https://www.atlassian.com/git/tutorials/undoing-changes/git-rm) - Rewriting history - [Overview](https://www.atlassian.com/git/tutorials/rewriting-history) - [git rebase](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase) - [git reflog](https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog) - Collaborating workflows - Syncing (git remote) - [Overview](https://www.atlassian.com/git/tutorials/syncing) - [git fetch](https://www.atlassian.com/git/tutorials/syncing/git-fetch) - [git push](https://www.atlassian.com/git/tutorials/syncing/git-push) - [git pull](https://www.atlassian.com/git/tutorials/syncing/git-pull) - [Making a Pull Request](https://www.atlassian.com/git/tutorials/making-a-pull-request) - Using Branches (Git branch) - [Overview](https://www.atlassian.com/git/tutorials/using-branches) - [git checkout](https://www.atlassian.com/git/tutorials/using-branches/git-checkout) - [git merge](https://www.atlassian.com/git/tutorials/using-branches/git-merge) - [Merge conflicts](https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts) - [Merge strategies](https://www.atlassian.com/git/tutorials/using-branches/merge-strategy) - Comparing Workflows - [Overview](https://www.atlassian.com/git/tutorials/comparing-workflows) - [Feature Branch Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) - [Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) - [Forking Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow) - Migrating to Git - [SVN to Git - prepping for the migration](https://www.atlassian.com/git/tutorials/svn-to-git-prepping-your-team-migration) - Migrate to Git from SVN - [Overview](https://www.atlassian.com/git/tutorials/migrating-overview) - [Prepare](https://www.atlassian.com/git/tutorials/migrating-prepare) - [Convert](https://www.atlassian.com/git/tutorials/migrating-convert) - [Synchronize](https://www.atlassian.com/git/tutorials/migrating-synchronize) - [Share](https://www.atlassian.com/git/tutorials/migrating-share) - [Migrate](https://www.atlassian.com/git/tutorials/migrating-migrate) - [Perforce to Git - why to make the move](https://www.atlassian.com/git/tutorials/perforce-git) - [Migrating from Perforce to Git](https://www.atlassian.com/git/tutorials/perforce-git-migration) - [Working with Git and Perforce: integration workflow](https://www.atlassian.com/git/tutorials/git-p4) - [How to move a Git repository with history](https://www.atlassian.com/git/tutorials/git-move-repository) - Advanced Tips - [Overview](https://www.atlassian.com/git/tutorials/advanced-overview) - [Merging vs. Rebasing](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) - [Reset, Checkout, and Revert](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting) - [Advanced Git log](https://www.atlassian.com/git/tutorials/git-log) - [Git Hooks](https://www.atlassian.com/git/tutorials/git-hooks) - [Refs and the Reflog](https://www.atlassian.com/git/tutorials/refs-and-the-reflog) - [Git submodules](https://www.atlassian.com/git/tutorials/git-submodule) - [Git subtree](https://www.atlassian.com/git/tutorials/git-subtree) - [Large repositories in Git](https://www.atlassian.com/git/tutorials/big-repositories) - [Git LFS](https://www.atlassian.com/git/tutorials/git-lfs) - [Git gc](https://www.atlassian.com/git/tutorials/git-gc) - [Git prune](https://www.atlassian.com/git/tutorials/git-prune) - [Git bash](https://www.atlassian.com/git/tutorials/git-bash) - [How to store dotfiles](https://www.atlassian.com/git/tutorials/dotfiles) - [Git cherry pick](https://www.atlassian.com/git/tutorials/cherry-pick) - [GitK](https://www.atlassian.com/git/tutorials/gitk) - [Git-show](https://www.atlassian.com/git/tutorials/git-show) - Articles - [Dealing with Maven dependencies when switching to Git](https://www.atlassian.com/git/articles/maven-dependencies-versions-merging) - [Pull request proficiency: Fetching abilities unlocked\!](https://www.atlassian.com/git/articles/pull-request-proficiency-fetching-abilities-unlocked) - [Git and project dependencies](https://www.atlassian.com/git/articles/git-and-project-dependencies) - [Git or SVN? How Nuance Healthcare Chose a Git Branching Model](https://www.atlassian.com/git/articles/git-or-svn-git-branching-model) - [Git Forks And Upstreams: How-to and a cool tip](https://www.atlassian.com/git/tutorials/git-forks-and-upstreams) - [Core concept, workflows and tips](https://www.atlassian.com/git/articles/core-concept-workflows-and-tips) Git topics - Learn Git - [Git commands](https://www.atlassian.com/git/glossary) - [Learn Git with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud) - [Learn about code review in Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-about-code-review-in-bitbucket-cloud) - [Learn Branching with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-branching-with-bitbucket-cloud) - [Learn Undoing Changes with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-undoing-changes-with-bitbucket) - Beginner - [What is version control](https://www.atlassian.com/git/tutorials/what-is-version-control) - [Source Code Management](https://www.atlassian.com/git/tutorials/source-code-management) - [What is Git](https://www.atlassian.com/git/tutorials/what-is-git) - [Why Git for your organization](https://www.atlassian.com/git/tutorials/why-git) - [Install Git](https://www.atlassian.com/git/tutorials/install-git) - [Git SSH](https://www.atlassian.com/git/tutorials/git-ssh) - [Git archive](https://www.atlassian.com/git/tutorials/export-git-archive) - [GitOps](https://www.atlassian.com/git/tutorials/gitops) - [Git cheat sheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) - Getting started - Setting up a repository - [Overview](https://www.atlassian.com/git/tutorials/setting-up-a-repository) - [git init](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init) - [git clone](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone) - [git config](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config) - [git alias](https://www.atlassian.com/git/tutorials/git-alias) - Saving changes (Git add) - [Overview](https://www.atlassian.com/git/tutorials/saving-changes) - [git commit](https://www.atlassian.com/git/tutorials/saving-changes/git-commit) - [git diff](https://www.atlassian.com/git/tutorials/saving-changes/git-diff) - [git stash](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) - [.gitignore](https://www.atlassian.com/git/tutorials/saving-changes/gitignore) - Inspecting a repository - [Overview](https://www.atlassian.com/git/tutorials/inspecting-a-repository) - [git tag](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-tag) - [git blame](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-blame) - Undoing changes - [Overview](https://www.atlassian.com/git/tutorials/undoing-changes) - [git clean](https://www.atlassian.com/git/tutorials/undoing-changes/git-clean) - [git revert](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert) - [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset) - [git rm](https://www.atlassian.com/git/tutorials/undoing-changes/git-rm) - Rewriting history - [Overview](https://www.atlassian.com/git/tutorials/rewriting-history) - [git rebase](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase) - [git reflog](https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog) - Collaborating workflows - Syncing (git remote) - [Overview](https://www.atlassian.com/git/tutorials/syncing) - [git fetch](https://www.atlassian.com/git/tutorials/syncing/git-fetch) - [git push](https://www.atlassian.com/git/tutorials/syncing/git-push) - [git pull](https://www.atlassian.com/git/tutorials/syncing/git-pull) - [Making a Pull Request](https://www.atlassian.com/git/tutorials/making-a-pull-request) - Using Branches (Git branch) - [Overview](https://www.atlassian.com/git/tutorials/using-branches) - [git checkout](https://www.atlassian.com/git/tutorials/using-branches/git-checkout) - [git merge](https://www.atlassian.com/git/tutorials/using-branches/git-merge) - [Merge conflicts](https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts) - [Merge strategies](https://www.atlassian.com/git/tutorials/using-branches/merge-strategy) - Comparing Workflows - [Overview](https://www.atlassian.com/git/tutorials/comparing-workflows) - [Feature Branch Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) - [Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) - [Forking Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow) - Migrating to Git - [SVN to Git - prepping for the migration](https://www.atlassian.com/git/tutorials/svn-to-git-prepping-your-team-migration) - Migrate to Git from SVN - [Overview](https://www.atlassian.com/git/tutorials/migrating-overview) - [Prepare](https://www.atlassian.com/git/tutorials/migrating-prepare) - [Convert](https://www.atlassian.com/git/tutorials/migrating-convert) - [Synchronize](https://www.atlassian.com/git/tutorials/migrating-synchronize) - [Share](https://www.atlassian.com/git/tutorials/migrating-share) - [Migrate](https://www.atlassian.com/git/tutorials/migrating-migrate) - [Perforce to Git - why to make the move](https://www.atlassian.com/git/tutorials/perforce-git) - [Migrating from Perforce to Git](https://www.atlassian.com/git/tutorials/perforce-git-migration) - [Working with Git and Perforce: integration workflow](https://www.atlassian.com/git/tutorials/git-p4) - [How to move a Git repository with history](https://www.atlassian.com/git/tutorials/git-move-repository) - Advanced Tips - [Overview](https://www.atlassian.com/git/tutorials/advanced-overview) - [Merging vs. Rebasing](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) - [Reset, Checkout, and Revert](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting) - [Advanced Git log](https://www.atlassian.com/git/tutorials/git-log) - [Git Hooks](https://www.atlassian.com/git/tutorials/git-hooks) - [Refs and the Reflog](https://www.atlassian.com/git/tutorials/refs-and-the-reflog) - [Git submodules](https://www.atlassian.com/git/tutorials/git-submodule) - [Git subtree](https://www.atlassian.com/git/tutorials/git-subtree) - [Large repositories in Git](https://www.atlassian.com/git/tutorials/big-repositories) - [Git LFS](https://www.atlassian.com/git/tutorials/git-lfs) - [Git gc](https://www.atlassian.com/git/tutorials/git-gc) - [Git prune](https://www.atlassian.com/git/tutorials/git-prune) - [Git bash](https://www.atlassian.com/git/tutorials/git-bash) - [How to store dotfiles](https://www.atlassian.com/git/tutorials/dotfiles) - [Git cherry pick](https://www.atlassian.com/git/tutorials/cherry-pick) - [GitK](https://www.atlassian.com/git/tutorials/gitk) - [Git-show](https://www.atlassian.com/git/tutorials/git-show) - Articles - [Dealing with Maven dependencies when switching to Git](https://www.atlassian.com/git/articles/maven-dependencies-versions-merging) - [Pull request proficiency: Fetching abilities unlocked\!](https://www.atlassian.com/git/articles/pull-request-proficiency-fetching-abilities-unlocked) - [Git and project dependencies](https://www.atlassian.com/git/articles/git-and-project-dependencies) - [Git or SVN? How Nuance Healthcare Chose a Git Branching Model](https://www.atlassian.com/git/articles/git-or-svn-git-branching-model) - [Git Forks And Upstreams: How-to and a cool tip](https://www.atlassian.com/git/tutorials/git-forks-and-upstreams) - [Core concept, workflows and tips](https://www.atlassian.com/git/articles/core-concept-workflows-and-tips) Git topics - Learn Git - [Git commands](https://www.atlassian.com/git/glossary) - [Learn Git with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud) - [Learn about code review in Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-about-code-review-in-bitbucket-cloud) - [Learn Branching with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-branching-with-bitbucket-cloud) - [Learn Undoing Changes with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-undoing-changes-with-bitbucket) - Beginner - [What is version control](https://www.atlassian.com/git/tutorials/what-is-version-control) - [Source Code Management](https://www.atlassian.com/git/tutorials/source-code-management) - [What is Git](https://www.atlassian.com/git/tutorials/what-is-git) - [Why Git for your organization](https://www.atlassian.com/git/tutorials/why-git) - [Install Git](https://www.atlassian.com/git/tutorials/install-git) - [Git SSH](https://www.atlassian.com/git/tutorials/git-ssh) - [Git archive](https://www.atlassian.com/git/tutorials/export-git-archive) - [GitOps](https://www.atlassian.com/git/tutorials/gitops) - [Git cheat sheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) - Getting started - Setting up a repository - [Overview](https://www.atlassian.com/git/tutorials/setting-up-a-repository) - [git init](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init) - [git clone](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone) - [git config](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config) - [git alias](https://www.atlassian.com/git/tutorials/git-alias) - Saving changes (Git add) - [Overview](https://www.atlassian.com/git/tutorials/saving-changes) - [git commit](https://www.atlassian.com/git/tutorials/saving-changes/git-commit) - [git diff](https://www.atlassian.com/git/tutorials/saving-changes/git-diff) - [git stash](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) - [.gitignore](https://www.atlassian.com/git/tutorials/saving-changes/gitignore) - Inspecting a repository - [Overview](https://www.atlassian.com/git/tutorials/inspecting-a-repository) - [git tag](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-tag) - [git blame](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-blame) - Undoing changes - [Overview](https://www.atlassian.com/git/tutorials/undoing-changes) - [git clean](https://www.atlassian.com/git/tutorials/undoing-changes/git-clean) - [git revert](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert) - [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset) - [git rm](https://www.atlassian.com/git/tutorials/undoing-changes/git-rm) - Rewriting history - [Overview](https://www.atlassian.com/git/tutorials/rewriting-history) - [git rebase](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase) - [git reflog](https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog) - Collaborating workflows - Syncing (git remote) - [Overview](https://www.atlassian.com/git/tutorials/syncing) - [git fetch](https://www.atlassian.com/git/tutorials/syncing/git-fetch) - [git push](https://www.atlassian.com/git/tutorials/syncing/git-push) - [git pull](https://www.atlassian.com/git/tutorials/syncing/git-pull) - [Making a Pull Request](https://www.atlassian.com/git/tutorials/making-a-pull-request) - Using Branches (Git branch) - [Overview](https://www.atlassian.com/git/tutorials/using-branches) - [git checkout](https://www.atlassian.com/git/tutorials/using-branches/git-checkout) - [git merge](https://www.atlassian.com/git/tutorials/using-branches/git-merge) - [Merge conflicts](https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts) - [Merge strategies](https://www.atlassian.com/git/tutorials/using-branches/merge-strategy) - Comparing Workflows - [Overview](https://www.atlassian.com/git/tutorials/comparing-workflows) - [Feature Branch Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) - [Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) - [Forking Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow) - Migrating to Git - [SVN to Git - prepping for the migration](https://www.atlassian.com/git/tutorials/svn-to-git-prepping-your-team-migration) - Migrate to Git from SVN - [Overview](https://www.atlassian.com/git/tutorials/migrating-overview) - [Prepare](https://www.atlassian.com/git/tutorials/migrating-prepare) - [Convert](https://www.atlassian.com/git/tutorials/migrating-convert) - [Synchronize](https://www.atlassian.com/git/tutorials/migrating-synchronize) - [Share](https://www.atlassian.com/git/tutorials/migrating-share) - [Migrate](https://www.atlassian.com/git/tutorials/migrating-migrate) - [Perforce to Git - why to make the move](https://www.atlassian.com/git/tutorials/perforce-git) - [Migrating from Perforce to Git](https://www.atlassian.com/git/tutorials/perforce-git-migration) - [Working with Git and Perforce: integration workflow](https://www.atlassian.com/git/tutorials/git-p4) - [How to move a Git repository with history](https://www.atlassian.com/git/tutorials/git-move-repository) - Advanced Tips - [Overview](https://www.atlassian.com/git/tutorials/advanced-overview) - [Merging vs. Rebasing](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) - [Reset, Checkout, and Revert](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting) - [Advanced Git log](https://www.atlassian.com/git/tutorials/git-log) - [Git Hooks](https://www.atlassian.com/git/tutorials/git-hooks) - [Refs and the Reflog](https://www.atlassian.com/git/tutorials/refs-and-the-reflog) - [Git submodules](https://www.atlassian.com/git/tutorials/git-submodule) - [Git subtree](https://www.atlassian.com/git/tutorials/git-subtree) - [Large repositories in Git](https://www.atlassian.com/git/tutorials/big-repositories) - [Git LFS](https://www.atlassian.com/git/tutorials/git-lfs) - [Git gc](https://www.atlassian.com/git/tutorials/git-gc) - [Git prune](https://www.atlassian.com/git/tutorials/git-prune) - [Git bash](https://www.atlassian.com/git/tutorials/git-bash) - [How to store dotfiles](https://www.atlassian.com/git/tutorials/dotfiles) - [Git cherry pick](https://www.atlassian.com/git/tutorials/cherry-pick) - [GitK](https://www.atlassian.com/git/tutorials/gitk) - [Git-show](https://www.atlassian.com/git/tutorials/git-show) - Articles - [Dealing with Maven dependencies when switching to Git](https://www.atlassian.com/git/articles/maven-dependencies-versions-merging) - [Pull request proficiency: Fetching abilities unlocked\!](https://www.atlassian.com/git/articles/pull-request-proficiency-fetching-abilities-unlocked) - [Git and project dependencies](https://www.atlassian.com/git/articles/git-and-project-dependencies) - [Git or SVN? How Nuance Healthcare Chose a Git Branching Model](https://www.atlassian.com/git/articles/git-or-svn-git-branching-model) - [Git Forks And Upstreams: How-to and a cool tip](https://www.atlassian.com/git/tutorials/git-forks-and-upstreams) - [Core concept, workflows and tips](https://www.atlassian.com/git/articles/core-concept-workflows-and-tips) Git topics - Learn Git - [Git commands](https://www.atlassian.com/git/glossary) - [Learn Git with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud) - [Learn about code review in Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-about-code-review-in-bitbucket-cloud) - [Learn Branching with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-branching-with-bitbucket-cloud) - [Learn Undoing Changes with Bitbucket Cloud](https://www.atlassian.com/git/tutorials/learn-undoing-changes-with-bitbucket) - Beginner - [What is version control](https://www.atlassian.com/git/tutorials/what-is-version-control) - [Source Code Management](https://www.atlassian.com/git/tutorials/source-code-management) - [What is Git](https://www.atlassian.com/git/tutorials/what-is-git) - [Why Git for your organization](https://www.atlassian.com/git/tutorials/why-git) - [Install Git](https://www.atlassian.com/git/tutorials/install-git) - [Git SSH](https://www.atlassian.com/git/tutorials/git-ssh) - [Git archive](https://www.atlassian.com/git/tutorials/export-git-archive) - [GitOps](https://www.atlassian.com/git/tutorials/gitops) - [Git cheat sheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) - Getting started - Setting up a repository - [Overview](https://www.atlassian.com/git/tutorials/setting-up-a-repository) - [git init](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init) - [git clone](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-clone) - [git config](https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config) - [git alias](https://www.atlassian.com/git/tutorials/git-alias) - Saving changes (Git add) - [Overview](https://www.atlassian.com/git/tutorials/saving-changes) - [git commit](https://www.atlassian.com/git/tutorials/saving-changes/git-commit) - [git diff](https://www.atlassian.com/git/tutorials/saving-changes/git-diff) - [git stash](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) - [.gitignore](https://www.atlassian.com/git/tutorials/saving-changes/gitignore) - Inspecting a repository - [Overview](https://www.atlassian.com/git/tutorials/inspecting-a-repository) - [git tag](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-tag) - [git blame](https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-blame) - Undoing changes - [Overview](https://www.atlassian.com/git/tutorials/undoing-changes) - [git clean](https://www.atlassian.com/git/tutorials/undoing-changes/git-clean) - [git revert](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert) - [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset) - [git rm](https://www.atlassian.com/git/tutorials/undoing-changes/git-rm) - Rewriting history - [Overview](https://www.atlassian.com/git/tutorials/rewriting-history) - [git rebase](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase) - [git reflog](https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog) - Collaborating workflows - Syncing (git remote) - [Overview](https://www.atlassian.com/git/tutorials/syncing) - [git fetch](https://www.atlassian.com/git/tutorials/syncing/git-fetch) - [git push](https://www.atlassian.com/git/tutorials/syncing/git-push) - [git pull](https://www.atlassian.com/git/tutorials/syncing/git-pull) - [Making a Pull Request](https://www.atlassian.com/git/tutorials/making-a-pull-request) - Using Branches (Git branch) - [Overview](https://www.atlassian.com/git/tutorials/using-branches) - [git checkout](https://www.atlassian.com/git/tutorials/using-branches/git-checkout) - [git merge](https://www.atlassian.com/git/tutorials/using-branches/git-merge) - [Merge conflicts](https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts) - [Merge strategies](https://www.atlassian.com/git/tutorials/using-branches/merge-strategy) - Comparing Workflows - [Overview](https://www.atlassian.com/git/tutorials/comparing-workflows) - [Feature Branch Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) - [Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) - [Forking Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow) - Migrating to Git - [SVN to Git - prepping for the migration](https://www.atlassian.com/git/tutorials/svn-to-git-prepping-your-team-migration) - Migrate to Git from SVN - [Overview](https://www.atlassian.com/git/tutorials/migrating-overview) - [Prepare](https://www.atlassian.com/git/tutorials/migrating-prepare) - [Convert](https://www.atlassian.com/git/tutorials/migrating-convert) - [Synchronize](https://www.atlassian.com/git/tutorials/migrating-synchronize) - [Share](https://www.atlassian.com/git/tutorials/migrating-share) - [Migrate](https://www.atlassian.com/git/tutorials/migrating-migrate) - [Perforce to Git - why to make the move](https://www.atlassian.com/git/tutorials/perforce-git) - [Migrating from Perforce to Git](https://www.atlassian.com/git/tutorials/perforce-git-migration) - [Working with Git and Perforce: integration workflow](https://www.atlassian.com/git/tutorials/git-p4) - [How to move a Git repository with history](https://www.atlassian.com/git/tutorials/git-move-repository) - Advanced Tips - [Overview](https://www.atlassian.com/git/tutorials/advanced-overview) - [Merging vs. Rebasing](https://www.atlassian.com/git/tutorials/merging-vs-rebasing) - [Reset, Checkout, and Revert](https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting) - [Advanced Git log](https://www.atlassian.com/git/tutorials/git-log) - [Git Hooks](https://www.atlassian.com/git/tutorials/git-hooks) - [Refs and the Reflog](https://www.atlassian.com/git/tutorials/refs-and-the-reflog) - [Git submodules](https://www.atlassian.com/git/tutorials/git-submodule) - [Git subtree](https://www.atlassian.com/git/tutorials/git-subtree) - [Large repositories in Git](https://www.atlassian.com/git/tutorials/big-repositories) - [Git LFS](https://www.atlassian.com/git/tutorials/git-lfs) - [Git gc](https://www.atlassian.com/git/tutorials/git-gc) - [Git prune](https://www.atlassian.com/git/tutorials/git-prune) - [Git bash](https://www.atlassian.com/git/tutorials/git-bash) - [How to store dotfiles](https://www.atlassian.com/git/tutorials/dotfiles) - [Git cherry pick](https://www.atlassian.com/git/tutorials/cherry-pick) - [GitK](https://www.atlassian.com/git/tutorials/gitk) - [Git-show](https://www.atlassian.com/git/tutorials/git-show) - Articles - [Dealing with Maven dependencies when switching to Git](https://www.atlassian.com/git/articles/maven-dependencies-versions-merging) - [Pull request proficiency: Fetching abilities unlocked\!](https://www.atlassian.com/git/articles/pull-request-proficiency-fetching-abilities-unlocked) - [Git and project dependencies](https://www.atlassian.com/git/articles/git-and-project-dependencies) - [Git or SVN? How Nuance Healthcare Chose a Git Branching Model](https://www.atlassian.com/git/articles/git-or-svn-git-branching-model) - [Git Forks And Upstreams: How-to and a cool tip](https://www.atlassian.com/git/tutorials/git-forks-and-upstreams) - [Core concept, workflows and tips](https://www.atlassian.com/git/articles/core-concept-workflows-and-tips) # Resetting, checking out & reverting The [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset), [git checkout](https://www.atlassian.com/git/tutorials/using-branches/git-checkout), and [git revert](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert) commands are some of the most useful tools in your Git toolbox. They all let you undo some kind of change in your repository, and the first two commands can be used to manipulate either commits or individual files. Because they’re so similar, it’s very easy to mix up which command should be used in any given development scenario. In this article, we’ll compare the most common configurations of `git reset`, `git checkout`, and `git revert`. Hopefully, you’ll walk away with the confidence to navigate your repository using any of these commands. ![The three trees of Git](https://dam-cdn.atl.orangelogic.com/AssetLink/i327n6ab7j85lkncarksjdkjpu6vsw4l.svg) It helps to think about each command in terms of their effect on the three state management mechanisms of a Git repository: the working directory, the staged snapshot, and the commit history. These components are sometimes known as "The three trees" of Git. We explore the three trees in depth on the [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset) page. Keep these mechanisms in mind as you read through this article. A checkout is an operation that moves the `HEAD` ref pointer to a specified commit. To demonstrate this consider the following example. ![4 nodes with "main node" being the last one](https://dam-cdn.atl.orangelogic.com/AssetLink/q20k742yfq646i283f4x6rrk16iddpe5.png) This example demonstrates a sequence of commits on the `main` branch. The `HEAD` ref and `main` branch ref currently point to commit d. Now let us execute `git checkout b` ![4 nodes with main pointing at last node and head pointing at 2nd node](https://dam-cdn.atl.orangelogic.com/AssetLink/0g7p8ct5r76ko7b642t6ug4654i0315j.png) This is an update to the "Commit History" tree. The `git checkout` command can be used in a commit, or file level scope. A file level checkout will change the file's contents to those of the specific commit. A revert is an operation that takes a specified commit and creates a new commit which inverses the specified commit. `git revert` can only be run at a commit level scope and has no file level functionality. A reset is an operation that takes a specified commit and resets the "three trees" to match the state of the repository at that specified commit. A reset can be invoked in three different modes which correspond to the three trees. Checkout and reset are generally used for making local or private 'undos'. They modify the history of a repository that can cause conflicts when pushing to remote shared repositories. Revert is considered a safe operation for 'public undos' as it creates new history which can be shared remotely and doesn't overwrite history remote team members may be dependent on. ## Git reset vs revert vs checkout reference The table below sums up the most common use cases for all of these commands. Be sure to keep this reference handy, as you’ll undoubtedly need to use at least some of them during your Git career. | Command | Scope | Common use cases | |---|---|---| | `git reset` | Commit-level | Discard commits in a private branch or throw away uncommitted changes | | `git reset` | File-level | Unstage a file | | `git checkout` | Commit-level | Switch between branches or inspect old snapshots | | `git checkout` | File-level | Discard changes in the working directory | | `git revert` | Commit-level | Undo commits in a public branch | | `git revert` | File-level | (N/A) | ## Commit level operations The parameters that you pass to `git reset` and `git checkout` determine their scope. When you don’t include a file path as a parameter, they operate on whole commits. That’s what we’ll be exploring in this section. Note that `git revert` has no file-level counterpart. ### Reset a specific commit On the commit-level, resetting is a way to move the tip of a branch to a different commit. This can be used to remove commits from the current branch. For example, the following command moves the `hotfix` branch backwards by two commits. ``` 1git checkout hotfix git reset HEAD~2 ``` The two commits that were on the end of `hotfix` are now dangling, or orphaned commits. This means they will be deleted the next time Git performs a garbage collection. In other words, you’re saying that you want to throw away these commits. This can be visualized as the following: ![Resetting the hotfix branch to HEAD-2](https://dam-cdn.atl.orangelogic.com/AssetLink/42y6ur245172f118hor8hyxk68ttntb3.png) This usage of `git reset` is a simple way to undo changes that haven’t been shared with anyone else. It’s your go-to command when you’ve started working on a feature and find yourself thinking, “Oh crap, what am I doing? I should just start over.” In addition to moving the current branch, you can also get `git reset` to alter the staged snapshot and/or the working directory by passing it one of the following flags: - `--soft` – The staged snapshot and working directory are not altered in any way. - `--mixed` – The staged snapshot is updated to match the specified commit, but the working directory is not affected. This is the default option. - `--hard` – The staged snapshot and the working directory are both updated to match the specified commit. It’s easier to think of these modes as defining the scope of a `git reset` operation. For further detailed information visit the [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset) page. ### Checkout old commits The `git checkout` command is used to update the state of the repository to a specific point in the projects history. When passed with a branch name, it lets you switch between branches. ``` 1git checkout hotfix ``` Internally, all the above command does is move `HEAD` to a different branch and update the working directory to match. Since this has the potential to overwrite local changes, Git forces you to commit or [stash](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) any changes in the working directory that will be lost during the checkout operation. Unlike `git reset`, `git checkout` doesn’t move any branches around. ![Moving HEAD from main to hotfix](https://dam-cdn.atl.orangelogic.com/AssetLink/5025uu83tl6p0032l5i525q5c72736p0.png) You can also check out arbitrary commits by passing the commit reference instead of a branch. This does the exact same thing as checking out a branch: it moves the `HEAD` reference to the specified commit. For example, the following command will check out the grandparent of the current commit: ``` 1git checkout HEAD~2 ``` ![Moving \`HEAD\` to an arbitrary commit](https://dam-cdn.atl.orangelogic.com/AssetLink/5e1l038ot14xi8ak55s7pn3wghla06f5.svg) This is useful for quickly inspecting an old version of your project. However, since there is no branch reference to the current `HEAD`, this puts you in a detached `HEAD` state. This can be dangerous if you start adding new commits because there will be no way to get back to them after you switch to another branch. For this reason, you should always create a new branch before adding commits to a detached `HEAD`. ### Undo public commits with revert Reverting undoes a commit by creating a new commit. This is a safe way to undo changes, as it has no chance of re-writing the commit history. For example, the following command will figure out the changes contained in the 2nd to last commit, create a new commit undoing those changes, and tack the new commit onto the existing project. ``` 1git checkout hotfix git revert HEAD~2 ``` This can be visualized as the following: ![Reverting the 2nd to last commit](https://dam-cdn.atl.orangelogic.com/AssetLink/21n8lc7l8s817wqs3dw21050rpsvhbf8.svg) Contrast this with `git reset`, which *does* alter the existing commit history. For this reason, `git revert` should be used to undo changes on a public branch, and `git reset` should be reserved for undoing changes on a private branch. You can also think of `git revert` as a tool for undoing *committed* changes, while `git reset HEAD` is for undoing *uncommitted* changes. Like `git checkout`, `git revert` has the potential to overwrite files in the working directory, so it will ask you to commit or [stash changes](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) that would be lost during the revert operation. ## File-level operations The `git reset` and `git checkout` commands also accept an optional file path as a parameter. This dramatically alters their behavior. Instead of operating on entire snapshots, this forces them to limit their operations to a single file. ### Git reset a specific file When invoked with a file path, `git reset` updates the *staged snapshot* to match the version from the specified commit. For example, this command will fetch the version of `foo.py` in the 2nd-to-last commit and stage it for the next commit: ``` 1git reset HEAD~2 foo.py ``` As with the commit-level version of `git reset`, this is more commonly used with `HEAD` rather than an arbitrary commit. Running `git reset HEAD foo.py` will unstage `foo.py`. The changes it contains will still be present in the working directory. ![Moving a file from the commit history into the staged snapshot](https://dam-cdn.atl.orangelogic.com/AssetLink/06m01u58ak1j203u3g6x4753toxg07r1.svg) The `--soft`, `--mixed`, and `--hard` flags do not have any effect on the file-level version of `git reset`, as the staged snapshot is *always* updated, and the working directory is *never* updated. ### Git checkout file Checking out a file is similar to using `git reset` with a file path, except it updates the *working directory* instead of the stage. Unlike the commit-level version of this command, this does not move the `HEAD` reference, which means that you won’t switch branches. ![Moving a file from the commit history into the working directory](https://dam-cdn.atl.orangelogic.com/AssetLink/j77yi336821qsf1gb3w22p51arjfxi2a.svg) For example, the following command makes `foo.py` in the working directory match the one from the 2nd-to-last commit: ``` 1git checkout HEAD~2 foo.py ``` Just like the commit-level invocation of `git checkout`, this can be used to inspect old versions of a project—but the scope is limited to the specified file. If you stage and commit the checked-out file, this has the effect of “reverting” to the old version of that file. Note that this removes *all* of the subsequent changes to the file, whereas the `git revert` command undoes only the changes introduced by the specified commit. Like `git reset`, this is commonly used with `HEAD` as the commit reference. For instance, `git checkout HEAD foo.py` has the effect of discarding unstaged changes to `foo.py`. This is similar behavior to `git reset HEAD --hard`, but it operates only on the specified file. ## Summary You should now have all the tools you could ever need to undo changes in a Git repository. The [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset), [git checkout](https://www.atlassian.com/git/tutorials/using-branches/git-checkout), and [git revert](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert) commands can be confusing, but when you think about their effects on the working directory, staged snapshot, and commit history, it should be easier to discern which command fits the development task at hand. ## Recommended for you ### Bitbucket blog [Learn more](https://www.atlassian.com/blog/bitbucket) ### DevOps learning path [Learn more](https://university.atlassian.com/student/activity/2483065-hello-and-welcome) ### Learn more about Git Find more Git guides and resources in this hub. [Read more](https://www.atlassian.com/git) - [Company](https://www.atlassian.com/company) - [Careers](https://www.atlassian.com/company/careers) - [Events](https://www.atlassian.com/company/events) - [Blogs](https://www.atlassian.com/blog) - [Investor Relations](https://investors.atlassian.com/) - [Atlassian Foundation](https://www.atlassianfoundation.org/) - [Press kit](https://www.atlassian.com/company/news/press-kit) - [Contact us](https://www.atlassian.com/company/contact) ## Products - [Rovo](https://www.atlassian.com/rovo) - [Jira](https://www.atlassian.com/software/jira) - [Jira Align](https://www.atlassian.com/software/jira/align) - [Jira Service Management](https://www.atlassian.com/software/jira/service-management) - [Confluence](https://www.atlassian.com/software/confluence) - [Loom](https://www.atlassian.com/software/loom) - [Trello](https://trello.com/home) - [Bitbucket](https://www.atlassian.com/software/bitbucket) - [See all products](https://www.atlassian.com/software) ## Resources - [Technical support](https://support.atlassian.com/) - [Purchasing & licensing](https://www.atlassian.com/licensing/purchase-licensing) - [Atlassian Community](https://community.atlassian.com/) - [Knowledge base](https://confluence.atlassian.com/kb) - [Marketplace](https://marketplace.atlassian.com/) - [My account](https://my.atlassian.com/products/index) - [Create support ticket](https://support.atlassian.com/contact/) ## Learn - [Partners](https://www.atlassian.com/partners) - [Training & certification](https://www.atlassian.com/university) - [Documentation](https://confluence.atlassian.com/display/ALLDOC/Atlassian+Documentation) - [Developer resources](https://www.atlassian.com/developers) - [Enterprise services](https://www.atlassian.com/enterprise/services) - [See all resources](https://www.atlassian.com/resources) Copyright © 2026 Atlassian - [Privacy policy](https://www.atlassian.com/legal/privacy-policy) - [Notice at Collection](https://www.atlassian.com/legal/privacy-policy#additional-disclosures-for-ca-residents) - [Terms](https://www.atlassian.com/legal/cloud-terms-of-service) - [Impressum](https://www.atlassian.com/legal/impressum) Language selector English ▾
Readable Markdown
The [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset), [git checkout](https://www.atlassian.com/git/tutorials/using-branches/git-checkout), and [git revert](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert) commands are some of the most useful tools in your Git toolbox. They all let you undo some kind of change in your repository, and the first two commands can be used to manipulate either commits or individual files. Because they’re so similar, it’s very easy to mix up which command should be used in any given development scenario. In this article, we’ll compare the most common configurations of `git reset`, `git checkout`, and `git revert`. Hopefully, you’ll walk away with the confidence to navigate your repository using any of these commands. ![The three trees of Git](https://dam-cdn.atl.orangelogic.com/AssetLink/i327n6ab7j85lkncarksjdkjpu6vsw4l.svg) It helps to think about each command in terms of their effect on the three state management mechanisms of a Git repository: the working directory, the staged snapshot, and the commit history. These components are sometimes known as "The three trees" of Git. We explore the three trees in depth on the [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset) page. Keep these mechanisms in mind as you read through this article. A checkout is an operation that moves the `HEAD` ref pointer to a specified commit. To demonstrate this consider the following example. ![4 nodes with "main node" being the last one](https://dam-cdn.atl.orangelogic.com/AssetLink/q20k742yfq646i283f4x6rrk16iddpe5.png) This example demonstrates a sequence of commits on the `main` branch. The `HEAD` ref and `main` branch ref currently point to commit d. Now let us execute `git checkout b` ![4 nodes with main pointing at last node and head pointing at 2nd node](https://dam-cdn.atl.orangelogic.com/AssetLink/0g7p8ct5r76ko7b642t6ug4654i0315j.png) This is an update to the "Commit History" tree. The `git checkout` command can be used in a commit, or file level scope. A file level checkout will change the file's contents to those of the specific commit. A revert is an operation that takes a specified commit and creates a new commit which inverses the specified commit. `git revert` can only be run at a commit level scope and has no file level functionality. A reset is an operation that takes a specified commit and resets the "three trees" to match the state of the repository at that specified commit. A reset can be invoked in three different modes which correspond to the three trees. Checkout and reset are generally used for making local or private 'undos'. They modify the history of a repository that can cause conflicts when pushing to remote shared repositories. Revert is considered a safe operation for 'public undos' as it creates new history which can be shared remotely and doesn't overwrite history remote team members may be dependent on. Git reset vs revert vs checkout reference The table below sums up the most common use cases for all of these commands. Be sure to keep this reference handy, as you’ll undoubtedly need to use at least some of them during your Git career. | Command | Scope | Common use cases | |---|---|---| | `git reset` | Commit-level | Discard commits in a private branch or throw away uncommitted changes | | `git reset` | File-level | Unstage a file | | `git checkout` | Commit-level | Switch between branches or inspect old snapshots | | `git checkout` | File-level | Discard changes in the working directory | | `git revert` | Commit-level | Undo commits in a public branch | | `git revert` | File-level | (N/A) | Commit level operations The parameters that you pass to `git reset` and `git checkout` determine their scope. When you don’t include a file path as a parameter, they operate on whole commits. That’s what we’ll be exploring in this section. Note that `git revert` has no file-level counterpart. Reset a specific commit On the commit-level, resetting is a way to move the tip of a branch to a different commit. This can be used to remove commits from the current branch. For example, the following command moves the `hotfix` branch backwards by two commits. ``` git checkout hotfix git reset HEAD~2 ``` The two commits that were on the end of `hotfix` are now dangling, or orphaned commits. This means they will be deleted the next time Git performs a garbage collection. In other words, you’re saying that you want to throw away these commits. This can be visualized as the following: ![Resetting the hotfix branch to HEAD-2](https://dam-cdn.atl.orangelogic.com/AssetLink/42y6ur245172f118hor8hyxk68ttntb3.png) This usage of `git reset` is a simple way to undo changes that haven’t been shared with anyone else. It’s your go-to command when you’ve started working on a feature and find yourself thinking, “Oh crap, what am I doing? I should just start over.” In addition to moving the current branch, you can also get `git reset` to alter the staged snapshot and/or the working directory by passing it one of the following flags: - `--soft` – The staged snapshot and working directory are not altered in any way. - `--mixed` – The staged snapshot is updated to match the specified commit, but the working directory is not affected. This is the default option. - `--hard` – The staged snapshot and the working directory are both updated to match the specified commit. It’s easier to think of these modes as defining the scope of a `git reset` operation. For further detailed information visit the [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset) page. Checkout old commits The `git checkout` command is used to update the state of the repository to a specific point in the projects history. When passed with a branch name, it lets you switch between branches. ``` git checkout hotfix ``` Internally, all the above command does is move `HEAD` to a different branch and update the working directory to match. Since this has the potential to overwrite local changes, Git forces you to commit or [stash](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) any changes in the working directory that will be lost during the checkout operation. Unlike `git reset`, `git checkout` doesn’t move any branches around. ![Moving HEAD from main to hotfix](https://dam-cdn.atl.orangelogic.com/AssetLink/5025uu83tl6p0032l5i525q5c72736p0.png) You can also check out arbitrary commits by passing the commit reference instead of a branch. This does the exact same thing as checking out a branch: it moves the `HEAD` reference to the specified commit. For example, the following command will check out the grandparent of the current commit: ``` git checkout HEAD~2 ``` ![Moving \`HEAD\` to an arbitrary commit](https://dam-cdn.atl.orangelogic.com/AssetLink/5e1l038ot14xi8ak55s7pn3wghla06f5.svg) This is useful for quickly inspecting an old version of your project. However, since there is no branch reference to the current `HEAD`, this puts you in a detached `HEAD` state. This can be dangerous if you start adding new commits because there will be no way to get back to them after you switch to another branch. For this reason, you should always create a new branch before adding commits to a detached `HEAD`. Undo public commits with revert Reverting undoes a commit by creating a new commit. This is a safe way to undo changes, as it has no chance of re-writing the commit history. For example, the following command will figure out the changes contained in the 2nd to last commit, create a new commit undoing those changes, and tack the new commit onto the existing project. ``` git checkout hotfix git revert HEAD~2 ``` This can be visualized as the following: ![Reverting the 2nd to last commit](https://dam-cdn.atl.orangelogic.com/AssetLink/21n8lc7l8s817wqs3dw21050rpsvhbf8.svg) Contrast this with `git reset`, which *does* alter the existing commit history. For this reason, `git revert` should be used to undo changes on a public branch, and `git reset` should be reserved for undoing changes on a private branch. You can also think of `git revert` as a tool for undoing *committed* changes, while `git reset HEAD` is for undoing *uncommitted* changes. Like `git checkout`, `git revert` has the potential to overwrite files in the working directory, so it will ask you to commit or [stash changes](https://www.atlassian.com/git/tutorials/saving-changes/git-stash) that would be lost during the revert operation. File-level operations The `git reset` and `git checkout` commands also accept an optional file path as a parameter. This dramatically alters their behavior. Instead of operating on entire snapshots, this forces them to limit their operations to a single file. Git reset a specific file When invoked with a file path, `git reset` updates the *staged snapshot* to match the version from the specified commit. For example, this command will fetch the version of `foo.py` in the 2nd-to-last commit and stage it for the next commit: ``` git reset HEAD~2 foo.py ``` As with the commit-level version of `git reset`, this is more commonly used with `HEAD` rather than an arbitrary commit. Running `git reset HEAD foo.py` will unstage `foo.py`. The changes it contains will still be present in the working directory. ![Moving a file from the commit history into the staged snapshot](https://dam-cdn.atl.orangelogic.com/AssetLink/06m01u58ak1j203u3g6x4753toxg07r1.svg) The `--soft`, `--mixed`, and `--hard` flags do not have any effect on the file-level version of `git reset`, as the staged snapshot is *always* updated, and the working directory is *never* updated. Git checkout file Checking out a file is similar to using `git reset` with a file path, except it updates the *working directory* instead of the stage. Unlike the commit-level version of this command, this does not move the `HEAD` reference, which means that you won’t switch branches. ![Moving a file from the commit history into the working directory](https://dam-cdn.atl.orangelogic.com/AssetLink/j77yi336821qsf1gb3w22p51arjfxi2a.svg) For example, the following command makes `foo.py` in the working directory match the one from the 2nd-to-last commit: ``` git checkout HEAD~2 foo.py ``` Just like the commit-level invocation of `git checkout`, this can be used to inspect old versions of a project—but the scope is limited to the specified file. If you stage and commit the checked-out file, this has the effect of “reverting” to the old version of that file. Note that this removes *all* of the subsequent changes to the file, whereas the `git revert` command undoes only the changes introduced by the specified commit. Like `git reset`, this is commonly used with `HEAD` as the commit reference. For instance, `git checkout HEAD foo.py` has the effect of discarding unstaged changes to `foo.py`. This is similar behavior to `git reset HEAD --hard`, but it operates only on the specified file. Summary You should now have all the tools you could ever need to undo changes in a Git repository. The [git reset](https://www.atlassian.com/git/tutorials/undoing-changes/git-reset), [git checkout](https://www.atlassian.com/git/tutorials/using-branches/git-checkout), and [git revert](https://www.atlassian.com/git/tutorials/undoing-changes/git-revert) commands can be confusing, but when you think about their effects on the working directory, staged snapshot, and commit history, it should be easier to discern which command fits the development task at hand.
Shard44 (laksa)
Root Hash11161217235333269644
Unparsed URLcom,atlassian!www,/git/tutorials/resetting-checking-out-and-reverting s443