Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ===== Overview ===== How to revert one or more commits, dealing with any possible merge conflicts along the way. ===== SYNOPSIS ===== <code> git revert [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>... git revert --continue git revert --quit git revert --abort </code> ===== DESCRIPTION ===== Note carefully //lack of traversal//: <code> <commit>... Commits to revert. For a more complete list of ways to spell commit names, see gitrevisions(7). Sets of commits can also be given but no traversal is done by default, see git-rev-list(1) and its --no-walk option. </code> ===== The variations ===== ==== Reverting a single commit ==== How: <code> $ git revert 2965b41 </code> which throws you into a commit edit session based on the earlier commit message: <code> Revert "HTTP->HTTPS" This reverts commit 2965b41fd84a1a76f56984ecdf6c123d1992730f. ... snip ... </code> The default is ''%%--%%edit'' if done from a terminal; you can override with ''%%--%%no-edit''. ==== Reverting a range of commits ==== Revert commits individually (revert ''v1.0'' (not included) up to and //including// ''v1.1''): <code> $ git revert v1.0..v1.1 </code> Revert commits in one operation but do not commit so you can tweak further: <code> $ git revert -n v1.0..v1.1 </code> ==== Reverting one file ==== <code> $ git diff HEAD HEAD^ -- <filename> | git apply - </code> git_revert.txt Last modified: 2019/03/13 12:49by rpjday