I often add some debug code while developing so I need to remove these changes later.
Currently, I check the git diff
and remove the changes manually or just type git checkout -- myfilename
if I would like to undo the entire file.
I love the interactive patch function (git add -i
). Is there a tool or a command in git which can undo changes interactive like git add -i
?
In other words: I would like to interactively checkout files and hunks out of the index.
Before Git 2.25 (Q1 2020), "
git reset --patch
$object
" would not work in a new repository (where there is no commit yet).Without any pathspec, it should allow a tree object to be given, but incorrectly required a committish, which has been corrected.
See commit 0a8e303 (24 Nov 2019) by Nika Layzell (
mystor
).(Merged by Junio C Hamano --
gitster
-- in commit 6b3cb32, 05 Dec 2019)What you are looking for I think is
git reset --patch
orgit reset -p
From the docs:
and about
git add -p
it saysSo basically with
git reset -p
you can select what you reset.Edit:
As the git checkout Manual Page mentions:
So the command you are looking for is