Now that you've seen how to use "git reset" to undo commits in order, starting with the most recent, let's take a look at how to use "git revert" to undo any commit regardless of when it was performed.

To help visualize this I'm going to open all four README.txt files that are inside the "sites/all/modules" directory. At the beginning of each file I'm going to add the text "This is an unwanted change." and save the files.

Now, I'll commit those changes.

  • git commit -am "This is where I made poor choices and bad edits."

Now, I'll install a few modules and commit them as individual commits.

  • drush up views -y
  • git add .
  • git commit -m "Updated views to 3.10"
  • drush dl entity
  • git add .
  • git commit -m "Installed entity 1.5"
  • drush dl admin_menu
  • git add .
  • git commit -m "Installed admin_menu 3.0-rc5"

Okay, so we've been working on our project for a while, and now we realize that we made some poor choices and bad edits, and committed them. Typing "git log --oneline" will show us that we've now made three commits since our poor choices and bad edits. We don't want to reset all of the changes since then, so we'll use "git revert " to undo those poor choices.

* git revert b5177fc

When we press Enter, we're taken to the commit message interface. If you just save and quit, the default message of "Revert """ will be used.

  • Type ":wq" and press Enter

Now, when we type "git log --oneline" we'll see the last commit is "Revert "This is where I made poor choices, and bad edits."", and if we open the README.txt files we'll see that the "This is an unwanted change." line has been removed from all of them.

What the DCO covers

What is Version Control and What is Git
init
status
add
commit
log
branch
checkout
merge
rebase

push
fetch
pull
clone

conflict resolution