Reset Commit History
Reset allows you to roll back commit history. The local commit history can be changed by removing one or more commits and either keeping or discarding staged and local working copy changes.
O (capital 0) in the Magit Status buffer opens the reset menu
||remove the commit, keep the staged and working directory changes|
||remove the commit, staged and working directory changes|
||remove the commit and staged changes, keep the working directory|
||remove staged changes only|
||remove working directory changes only|
||reset a specific file|
Using recent commits or log
Navigating the recent commits or log list,
l l, is a simple way to reset to a commit, especially further back in the history.
k to navigate to the commit in the history to reset to,the commit that will be the new HEAD.
O to initiate a reset and choose the scope of the reset to carry out (commit, staging, working directory).
Specifying a commit to reset to
Specify or select where to reset the commit history to
|Reset HEAD to||Description|
||no change, this is the latest commit|
||first commit before the latest|
||second commit before the latest|
All commits between the current HEAD new HEAD will be removed.
l l shows you the updated commit history.
Changing shared commit history
Avoid reverting shared history when possible, instead consider using revert
-f force option if you must push a changed history to a shared repository
P -f p to force push to a remote repository.