tags:

views:

343

answers:

2

Hello,

I have made several changes to a file and have also added it to the git index. While committing the file I realized that I actually have changes which should go in separate commits with other files.

Is there a way to commit only specific parts of this file in Git?

Thanks for your help.

-- Parag

+4  A: 

Use git gui, it can add only specific parts of a file to the index. I think you can do it using git add -i (interactive mode) too, but I've never used it.

Schnouki
For me "git gui" is easier to use than "git add --interactive".
Jakub Narębski
+7  A: 

Use:

git add -i

to add files interactively. This will allow you to stage only the parts of the files you wish to commit. More info here, and a decent tutorial here.

Mr. Matt
You can also run 'git add --patch' to skip directly to selecting hunks.
William Pursell