Quick Tip: Git Undo Commands

CodeWithCaen - Oct 17 - - Dev Community

To undo changes in Git, you can use the following commands, depending on what you want to undo:

Method 1: Undo uncommitted changes in the working directory:

git checkout -- <file>
Enter fullscreen mode Exit fullscreen mode

Method 2: Unstage a staged file:

git reset <file>
Enter fullscreen mode Exit fullscreen mode

Method 3: Undo the last commit but keep changes:

git reset --soft HEAD~1
Enter fullscreen mode Exit fullscreen mode

Method 4: Undo the last commit and discard changes:

git reset --hard HEAD~1
Enter fullscreen mode Exit fullscreen mode

Choose the command based on your requirement. Always be cautious with --hard as it irreversibly deletes changes.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player