0

Hi I can do hard reset of a file whose changes have not been staged and is currently in working directory by

git checkout HEAD -- my-file.txt

as mentioned here Hard reset of a single file.

But my question is how to reset a single file to the previous head not all other files when it is commited and also if it is pushed in the remote.

Community
  • 1
  • 1

2 Answers2

1
git checkout HEAD^ -- my-file.txt

will reset a file to the state it was in one commit before the most recent commit.

Andrew Bennet
  • 2,560
  • 1
  • 21
  • 54
-1

I am not sure but try to remove the commit which you want with "git rebase -i" command.

1615903
  • 28,988
  • 11
  • 62
  • 87
Yasss
  • 388
  • 2
  • 9