It’s just a matter of figuring out which commit you need to roll back. Using -m 2 will revert the second commit ( 62db4af). Let’s look at the merge commit shown above:Ĭommit 137ea95c911633d3e908f6906e3adf6372cfb0adīasically, if we do git revert HEAD~1 -m 1, you’ll get the first commit in the merge reverted ( 5f576a9). This requires a number argument, which is a bit misleading. By using the -m or -mainline option, you can pick out which commit should be part of the ‘mainline’. With merges, you need to pick one of the merged in commits to revert. You may receive this message when trying to revert one:įatal: Commit 137ea95 is a merge but no -m option was given. If you need to edit files further to complete the revert or possibly revert more than one commit, try out this option.įinally, dealing with reverting merges is somewhat irksome. This will simply leave the reverted changes in your working directory and not automatically commit them. Use this to explain why the changes are being backed out! If for some reason you don’t want to edit the commit message, tacking on -no-edit will allow you do so.Īnother helpful option is the -n or -no-commit flag. Of course, if the commit that you want to revert doesn’t apply cleanly you’re going to have to manually resolve the merge.īy default using this command will bring up your $EDITOR so you can modify the commit message of the revert. You can also pass in any SHA for any commit to revert those changes. "Revert "Updated to Rails 2.3.2 and edge hoptoad_notifier"" So, you wanted to revert the last commit you just made on your current branch: The “revert” command works like so: it basically reverses whatever changes made in the commit passed in by creating a new commit. Luckily, git revert is just the scalpel you need to extract that bad commit. Somehow though, that bug got into the repository, and now you need to get it out. Perhaps you didn’t have enough coffee that morning, or it was just before lunch.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |