Git reset and checkout by single command
Consider I’ve staged for committing a file (e.g.
db/schema.rb) that I didn’t intended to change. I need to do:
git reset db/schema.rb git checkout db/schema.rb
Can I do it by single command?
- Git: can't undo local changes (error: path … is unmerged)
- Git Reset - remotes/origin/master not in sync with local master
- Git: How to revert a force push
- Is a git commit required if I rollback using 1) git hard reset or 2) git revert?
- Undo git reset --hard after git stash pop
- Undoing a git reset to uncommited state before reset?
2 Solutions collect form web for “Git reset and checkout by single command”
I tried this one and works well for me:
git checkout HEAD -- path
Simply reset with option
git reset --HARD