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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top