$ git reset -- <file_path> can reset by path.
However, $ git reset (--hard|--soft) <file_path> will report an error like below:
Cannot do hard|soft reset with paths.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because there’s no point (other commands provide that functionality already), and it reduces the potential for doing the wrong thing by accident.
A “hard reset” for a path is just done with
git checkout HEAD -- <path>(checking out the existing version of the file).A soft reset for a path doesn’t make sense.
A mixed reset for a path is what
git reset -- <path>does.