To undo a git add operation (unstage files), the recommended command is git restore --staged. This moves changes from the staging area back to the working directory without losing any modifications.
Recommended Method:
git restore --stagedThis command is the preferred method in modern Git (versions 2.23+) because it is more intuitive and safer for this specific task.
- Unstage a specific file:(Replace
<filename>with the actual name of your file, e.g.,git restore --staged index.html). - Unstage all files:
Alternative Method:
git resetBefore
git restore was introduced, the git reset command was used to unstage files, and it still works.- Unstage a specific file:
- Unstage all files:
No comments:
Post a Comment