1

Case Scenario

Let's assume that I have 3 files:

 Dir/
     a.py
     b.py
     c.py

and I have 10 commits, each one of which is involving changes to ALL of those three files.

For example commit with hash code ABCD is changing 3 lines from a, 10 lines from b and 1 line from c. Same stands for the rest for the commits.

At that point I am realizing that ALL the changes have been made in file a.py are useless.

  1. How can I revert ALL the changes of file a.py WITHOUT reverting my changes in the other two files?
  2. And what is the best practice to approach this kind of scenarios?
Daedalus
  • 295
  • 2
  • 17

1 Answers1

3

This will do: git checkout <commit_hash> -- <file>.

It will reset this specific file to the specified commit.

jburtondev
  • 2,827
  • 1
  • 14
  • 20