Skip to content

Latest commit

 

History

History
36 lines (22 loc) · 969 Bytes

File metadata and controls

36 lines (22 loc) · 969 Bytes

⬅️ Back to Useful Rare Git Commands You Never Heard Of

git replace

Category: History

Temporarily substitute one commit for another.

Command

git replace abc123 def456

Examples

  • Temporarily replace commit abc123 with def456.
git replace abc123 def456 
  • Graft a new parent onto a commit for testing history changes.
git replace --graft HEAD~2 HEAD 

Steps

  1. Run git replace <old-commit> <new-commit> to test or patch history.

➡️ Continue to Next Topic: How to Use git push --force-with-lease Safely


Author: mike-rambil • Updated: 2024-06-10 • Tags: replace, history