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
If you are using vim, you may want to try the excellent plugin called fugitive.
You can see the diff of a file between working copy and index with :Gdiff
, and then add lines or hunks to the index using classic vim diff commands like dp
. Save the modifications in the index and commit with :Gcommit
, and you're done.
Very good introductory screencasts here (see esp. part 2).