Commit only part of a file in Git

后端 未结 23 1978
一整个雨季
一整个雨季 2020-11-22 05:50

When I make changes to a file in Git, how can I commit only some of the changes?

For example, how could I commit only 15 lines out of 30 lines that have been changed

23条回答
  •  清酒与你
    2020-11-22 06:32

    Worth noting that to use git add --patch for a new file you need to first add the file to index with git add --intent-to-add:

    git add -N file
    git add -p file
    

提交回复
热议问题