-
To remove a file for example 'myfile.txt'; which is already committed and a part of repository, the first step is to 'staging' this file deletion using 'git rm myfile.txt' command.
-
After this command if we use 'git status' it'll show message
e.g.'deleted: myfile.txt'
-
Now as second step to make it permanently we have to commit this staging using 'git commit -m ' command.
-
Another way is if we remove the file 'myfile.txt' from the working directory manually for example using terminal rm command or using menu as we delete file normally using operating system's GUI. post manual removal the 'git status' command will display the message 'Changes not staged for commit:' and file information like 'deleted: myfile.txt'.
-
To stage these manual changes(we will say same behaviour as working directory changes of add/remove/update files) we've to use -u (recursively update) option with add
e.g. 'git add -u'(pre git 2.0 version) or 'git add .'(git 2.0 and above version) command.