Oops - How to Undo Anything
28%
Take a File Off the Stage
Sometimes you stage a file with git add and then realize you're not ready to commit it yet. You don't want to lose the changes - you just want to move the file back from "staged" to "modified."
Let's add a multiplication function and stage it:
cat << 'EOF' > calculator.py
# calculator.py - A simple calculator
def add(a, b):
"""Add two numbers and return the result."""
return a + b
def subtract(a, b):
"""Subtract b from a and return the result."""
return a - b
def multiply(a, b):
"""Multiply two numbers and return the result."""
return a * b
# Try it out
result_add = add(5, 3)
result_sub = subtract(10, 4)
result_mul = multiply(6, 7)
print(f"5 + 3 = {result_add}")
print(f"10 - 4 = {result_sub}")
print(f"6 * 7 = {result_mul}")
EOF
git add calculator.py
Now check the status:
Learn Git in a Day
Everything you need, nothing you don'tEnroll now to unlock all content and receive all future updates for free.
Unlock now $9.99$7.49Learn More
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
