14/03/2015 - GIT
You have files indexed before commit but you want to remove one of them from index so that you don't commit it accidentally. Changes to the file remain intact. For that, we use git reset
but it doesn't apply to "untracked" files. For more information, click git reset link.
inanzzz@inanzzz:~/project$ git status
On branch my-feature-branch
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: file_seven.txt
modified: file_two.txt
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: file_five.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
file_six.txt
inanzzz@inanzzz:~/project$ git reset HEAD file_two.txt
Unstaged changes after reset:
M file_five.txt
M file_two.txt
As we can see "file_two.php" has been unindexed.
inanzzz@inanzzz:~/project$ git status
On branch my-feature-branch
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: file_seven.txt
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: file_five.txt
modified: file_two.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
file_six.txt