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?

  • how do I get git to show me which branches are tracking what?
  • How to get a list of directories deleted in my git repository?
  • How do I restore from a previous commit on Xcode 8?
  • Removing git submodules - how to automate removal on pull?
  • git and subversion's plugin on the same IDE
  • Is there a tool to have git show “detached heads” in a graph?
  • change a git commit already pushed
  • Bamboo build stuck on “Waiting to be built…” and Cloning into 'Common'
  • Undo local changes in Git
  • GitHub - How to revert changes to previous state
  • Checkout branch from Github without cloning whole repo, and without Git
  • How can I set up autocompletion for Git commands?
  • 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 --HARD

    git reset --HARD
    Git Baby is a git and github fan, let's start git clone.