From the course: Git: Branches, Merges, and Remotes

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Hard reset

Hard reset

From the course: Git: Branches, Merges, and Remotes

Start my 1-month free trial

Hard reset

- [Instructor] Now that we know about soft and mixed resets, we're ready to learn about hard resets. Hard resets move the head pointer, they change the staging index to match the repository and they change the working directory to match the repository. We call it, the same way we've called the others using git reset with dash dash hard followed by a tree-ish. Now a hard reset is going to return to an old state and discard all subsequent code changes. It's useful to permanently undo commits, to make a branch look like something different completely. So previous commits and all changes will be discarded. That's why it's called a hard reset, it's the toughest one. And the same caveats apply. Be careful about amending commits which have been shared, because once you share code their repository's are still going to have commits, and yours won't, and it becomes hard to sync things back up again. Let's try a hard reset. I'm inside my explore California project and I'm already on my reset…

Contents