LuisVM LuisVM -4 years ago 95
Git Question

Is it possible to git-checkout a single line instead of the entire file?

If I have modified several lines of a versioned file, is it possible to undo the changes of a line by command-line?

Just like I would do for an entire file with:

git checkout /path/to/file.extension

but doing something like, say

git checkout /path/to/file.extension --line 10

is this possible?

Answer Source

You can use git checkout -p to see each hunk individually and decide whether to check them out or leave them as is (and that takes an optional path argument as well if you'd like to narrow it down further).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download