Visit Matillion AI Playground at Snowflake Data Cloud Summit 24

Find out more

Mastering Git at Matillion - Understanding Hard Reset

Welcome back to our Git series, where we explore various aspects of Git and how they help you control the different versions of your project. In this instalment, we delve into the concept of a "hard reset." Git offers a variety of tools for managing your project's state, and a hard reset is one of the most powerful—but also one of the most potentially risky—tools at your disposal. Let's discuss what a hard reset is, when it can be useful, and the precautions you should take when using it.

What is a Hard Reset in Git?

A hard reset in Git is an operation that allows you to return your local branch, including commit history, to a specific commit. Most commonly, and always in the Data Productivity Cloud, this is the most recent commit i.e. hard reset simply drops uncommitted changes. This operation erases all changes made since that commit, effectively reverting your branch to an earlier state. It can be a lifesaver when you need to undo a series of changes quickly or when you want to experiment without worrying about affecting the branch you’re on.

When is Hard Reset Useful?

Hard reset can be useful in various situations, particularly when you want to start fresh from a known good point.

If you've been working on a feature and decide to remove local changes or revert to a previous, committed state, a hard reset can help you return to this known state without committing unnecessary changes.

An example might be working experimentally in the main branch to find out how to fix a bug. Once you know the solution, you need to revert everything back to how it was in production, ready to push the fix cleanly through development.

It's important to note that a hard reset in the Data Productivity Cloud returns the project to the last committed state, which may differ from the last pushed state. This distinction is critical because, even after you hard reset, the local version of your branch will differ from the remote version if you have commits that are yet to be pushed or if there are commits upstream that are yet to be pulled.

The Dangers of Hard Reset

While hard reset can be useful, it also comes with risks. Here's what you should be aware of before using it:

  • Loss of uncommitted work: If you have uncommitted changes in your working directory or staging area, a hard reset will erase them.
  • Irreversible action: Once a hard reset is performed, you cannot undo it. There is no "undo" button, so make sure you're certain before proceeding.

Best Practices for Hard Reset

To use hard reset safely, consider these best practices:

  • Commit important work: Before performing a hard reset ensure you have committed critical changes.
  • Use with caution: Only use hard reset when you are confident that it's the correct action to take. Double-check the commit you want to reset to and ensure no essential work will be lost. Again, this is irrelevant in the Data Productivity Cloud since we only reset to the most recent commit.
  • Communicate with your team: If you're working in a team, communicate your intentions to avoid disrupting others' work. Of course, communicating clearly is always good practice when using version control.


In summary, a hard reset is a powerful Git feature that allows you to revert to a specific commit, providing a way to correct mistakes or start fresh. However, it comes with risks, and caution should be exercised when using it. By following best practices and understanding the implications, you can use hard reset to maintain control over your project's development.

Stay tuned for our next installment, where we'll be coveringCommits to push. Until then, happy merging and Git Good with the Data Productivity Cloud!

Catch up here for:

Part One on Commit, Push and Pull 

Part Two on Branching

Part Three on Exploring Common Branching Strategies 

Part Four on An In-depth Guide to Merging

Bryns Jones
Bryns Jones

Senior Engineering Manager

Bryns Jones is a Senior Engineering Manager working with the DataOps team at Matillion