Commit specific lines of a file to git

Git

Git Problem Overview


> Possible Duplicate:
> How can I commit only part of a file in git

How do I commit a few specific line ranges from a file to git? while ignoring some other line changes in the same file.

Git Solutions


Solution 1 - Git

Try git add -p -- it will interactively let you add, skip, or split diff hunks.

Solution 2 - Git

Use git add -i to stage the lines then commit as normal, or use git-cola until you get used to the command line.

Staging lines of a file

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionerikvoldView Question on Stackoverflow
Solution 1 - GitAdam DiCarloView Answer on Stackoverflow
Solution 2 - GitPeter CoultonView Answer on Stackoverflow