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.

Soft reset

Soft reset

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

Start my 1-month free trial

Soft reset

- [Instructor] Let's learn how to perform a soft reset and see why you might find it useful. As we've seen soft reset moves the HEAD pointer, it does not change the staging index, and it does not change the working directory, and the way that you call a soft reset is just to type git reset and then use the dash dash soft option followed by a tree-ish which could either be a SHA from a commit or a branch name or a tag name or something else, anything that points to some point in the repository's timeline. So why would you use a soft reset? You use it to return to an old state, but leave code changes staged, that makes it useful for amending one or more commits. We're saying let's roll back in time, but let's hold onto those changes and let's keep them in the staging area and in the working directory as if they're just not committed yet. It's a little bit similar to git commit amend. Now it's important to note that any time we do a reset previous commits will be discarded. If we go…

Contents