10/03/2015 - GIT
You want to remove a file from the current working tree and use git add --all
safely. It is removed completely from file system as well. For that, we use git rm --force
but it doesn't apply to "untracked" files. For more information, click git rm link.
inanzzz@inanzzz:~/project$ git status
On branch develop
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: file_four.txt
new file: file_three.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_two.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
file_one.txt
inanzzz@inanzzz:~/project$ git rm --force file_three.txt
rm 'file_three.txt'
As we can see, "file_three.txt" is not in working directory anymore and git add --all
can be used safely however if you do any updates to the file, it will appear in "untracked" section.
inanzzz@inanzzz:~/project$ git status
On branch develop
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: file_four.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_two.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
file_one.txt
As we can see, only three files have been committed.
inanzzz@inanzzz:~/project$ git add --all
inanzzz@inanzzz:~/project$ git commit -m 'Commit'
[develop 860fcb2] Commit
3 files changed, 8 insertions(+)
create mode 100644 file_one.txt