Tsallaka zuwa abun ciki
Justice Tech School

Revert: Undo Safely

git revert creates a new commit that reverses an earlier one. Use it on shared branches because history is not rewritten.

Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt && git commit -qam 'Add two'
git revert --no-edit HEAD >/dev/null
git log --format=%s
cat a.txt

Result

Revert "Add two"
Add two
first
one

Exercise

Undo a commit safely.

git  HEAD

Quiz Test

Why revert instead of reset on shared branches?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.