Git: Add part of (changed) file to index *by line numbers*

后端 未结 4 1870
长发绾君心
长发绾君心 2020-12-29 15:41

Is there a git command to add differences within a range of line-numbers to the index?

I want to be able to select lines in my editor and run a macro to add

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-29 16:29

    The easiest way to do it currently is with git add in interactive mode:

    git add -i path/to/file
    

    It will launch simple UI where you can choose chunks you want to stage and let you edit any chunk to remove lines you don't want to commit.

提交回复
热议问题