0

Committing only parts of your edits is possible by using either git add --interactive or git commit filename. However when combining both methods the results are unexpected.

For example you "stage" one out of four hunks in file1 (among other staging in different files). Then you want to commit only those changes staged for file1, using git commit file1 (git commit would only commit the staged changes of all files).

Unfortunately the result is that all changes made to file1 are committed.

Is this a bug, and if not: Is there a way to commit only the staged changes of a specific file?

U. Windl
  • 943

1 Answers1

1

I believe you are a little bit confused:

git add --interactive -- Interactive way to stage files.

git commit file -- commit only file. Staged changes ignored during this commit.

git add -p file -- partially stage changes of file

markalex
  • 363
  • 2
  • 13