SVN リポジトリを追跡している私の git リポジトリで、1 つのファイルにいくつかの編集を加えました。
ここで、これらの変更を元に戻したいのですが (svn revert のように)、ファイルの一部だけです。
ファイルの差分を表示し、不要な変更を破棄(元に戻し)し、必要な変更を保持できるようにしたいと考えています。
の
git add -i
コマンドにはそれを実行するオプションがあるようですが、まだこれをステージングしたくありません。
ベストアンサー1
最も簡単な方法は次のとおりだと思います:
git checkout -p <optional filename(s)>
マンページから:
−p, −−patch Interactively select hunks in the difference between the <tree−ish> (or the index, if unspecified) and the working tree. The chosen hunks are then applied in reverse to the working tree (and if a <tree−ish> was specified, the index).
This means that you can use git checkout −p to selectively discard
edits from your current working tree.