Git and GitHub

Backend Engineering

Git and GitHub

Undoing Changes and Time Travel

Undoing Changes and Time Travel

Undoing Changes with Git Reset

The git reset command undoes changes by resetting the current branch to a specific state.

Example:

# Unstage a file
git reset HEAD file.txt

Reverting Commits

The git revert command creates a new commit that undoes the changes of a previous commit.

Example:

# Revert a specific commit
git revert commit-hash

Detached HEAD State

In the detached HEAD state, you can view and make changes to previous commits without changing the branch.

Example:

# Checkout a specific commit (detached HEAD)
git checkout commit-hash

Restoring Files with Git Restore

The git restore command restores working tree files to match the index or another commit.

Example:

# Restore a file to the last commit
git restore file.txt

Whenever you're ready

There are 4 ways we can help you become a great backend engineer:

The MB Platform

Join 1000+ backend engineers learning backend engineering. Build real-world backend projects, learn from expert-vetted courses and roadmaps, track your learnings and set schedules, and solve backend engineering tasks, exercises, and challenges.

The MB Academy

The “MB Academy” is a 6-month intensive Advanced Backend Engineering BootCamp to produce great backend engineers.

Join Backend Weekly

If you like post like this, you will absolutely enjoy our exclusive weekly newsletter, Sharing exclusive backend engineering resources to help you become a great Backend Engineer.

Get Backend Jobs

Find over 2,000+ Tailored International Remote Backend Jobs or Reach 50,000+ backend engineers on the #1 Backend Engineering Job Board