Example:
» git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: a
modified: b
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: a
If I have modified a file named a, and add parts of it to index
, and there is a file named b also in index.
I want to commit only file a in index, neither include b nor a in work directory.
The way I use is to use git commit -p
and enter n
to not stage. or git commit -p file
and choose the part I want.
But if the part in file a already add in index, is there a better way to direct commit file a only in index part?
Supplement:
I think maybe that is wrong use of git.
Only the changes to be commited in the next commit, should add in the index.
Obvious the file b is not prepared to be commited, so it thould in the working directory.