Commit/Rollback Explained

What is Commit/Rollback?

Commit/Rollback is a fundamental concept in version control systems like Git. It describes the process of creating a snapshot of your project at a particular point in time, allowing you to revert to an earlier version if needed. It's not just about saving changes; it's about managing a history of modifications.

The Workflow

The typical workflow involves:

The Process

The core of a commit/rollback involves two key commands: `git revert` and `git reset`.

`git revert` creates a new commit that undoes the changes introduced by a previous commit. It's a safer option as it doesn't rewrite history; it just adds a record of the changes. It preserves the history of previous commits.

`git reset` moves the branch to a previous state. It effectively rewinds to a specific commit. This is useful for cleaning up your commit history or experimenting with different states.

Example

Let's say you've made a commit with a new feature. `git revert` will automatically update the history to reflect the previous version.

If you want to undo that feature, `git reset` could be used, but be careful as it alters the history.

Resources

Learn more: Git Commit Docs