📘
Git-Help
Git Cheatsheet
  • A Simple Git Help
  • Basics
  • Git Branching
  • Pull Request
  • Submodules
  • Commands / Actions
    • Commit changes to other branch
    • git log
    • git status
    • git init
    • Amend a commit
    • Reset a file or full
    • Undo git add
    • Get remote repo url
    • Add or Set Remote URL
    • delete branch
  • Credits & Other
    • Other good links
    • Credits
Powered by GitBook
On this page

Was this helpful?

  1. Commands / Actions

Reset a file or full

To reset a file to the original file

PreviousAmend a commitNextUndo git add

Last updated 3 years ago

Was this helpful?

To reset a file to its orginal file (remove your changes to the file abc.txt)

# With Git 2.23
git restore abc.txt  

# With older version of git
git checkout -- abc.txt

To do full reset a file (reset the file back to original remote format)

git checkout @ -- abc.txt

git checkout HEAD -- abc.txt

To reset a local branch exactly to the remote

git fetch origin
git reset --hard origin/master
Hard reset of a single fileStack Overflow
Logo