Question

Sometimes the hunks offered to you when you run git add --patch include unrelated changes mixed up with each other because the lines are physically close to each other in the file.

Is there a way to interactively add changes to the staging area on a line-by-line basis?

Was it helpful?

Solution

You can type e (for 'edit') when you are adding a specific patch with mixed content (too mixed for s or 'split' to work).

That allows you to delete the lines you don't want to add.

Then you can test what you have added with a git stash --keep-index, in order to see if that is working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top