


Git reset offers three main modes (or options) that determine how it behaves. The basic syntax for git reset is as follows: git reset Note that if you already pushed a set of changes to your remote repository such as on GitHub or BitBucket, you probably want to use the git revert command instead of reset. You can think of this as resetting the tip of your current branch to a previous state. The main result of using the git reset command is to repoint the branch label of your currently checked-out branch to a different (usually a previous) commit. Remember, a Git branch is basically just a label that points to the latest commit in a chain of commits. Essentially, Git will reset the tip of your current branch to a prior commit, and handle any uncommitted changes as you see fit. You can think of this as a way to "move backwards" in your Git flow (or Git history) if you need to undo changes in Git from any of these three locations. The object repository (or object database)Įxecuting git reset provides a way to reset changes that were made in any of these three locations.The working directory (or working tree).These three steps correspond with the following three Git concepts: Finally, you can run git commit to commit these changes to the repo. You then use the git add command to move your changes to Git's staging area (or index). You create or modify code files with a text editor directly in your Git working directory. The steps used for tracking changes with Git are fairly straightforward.
#Git stash restore how to#
In this article, we'll explain how to use the git reset command along with providing some git reset examples. In addition to tracking code changes, Git makes it easy to branch, merge, and review the history of the codebase.Īt a high level, the git reset command enables you to undo or "reset" code changes that you previously made. Git is a distributed version control system used for tracking changes made to code files within collaborative or open-source projects. git reset -mixed with commit parameter.
