O'Reilly logo

Continuous Integration, Delivery, and Deployment by Sander Rossel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reverting changes

Sometimes, you just want to get rid of whatever it is you did. Whether you just want to clean your working directory or you want to actually undo some items you (accidentally) committed, Git makes it possible.

There are a couple of scenarios we can think of that we want reverted. The first is quite simple. We have staged some files and we simply want to unstage everything. The git reset command does this:

git statusOn branch masterChanges to be committed: (use "git reset HEAD <file>..." to unstage) new file: accidentally added.txt modified: kernel.txt deleted: lasers.txtgit resetUnstaged changes after reset:M kernel.txtD lasers.txtgit statusOn branch masterChanges not staged for commit: (use "git add/rm <file>..." to update ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required