From: http://yang3wei.github.io/blog/2013/02/03/git-rm-he-rm-de-qu-bie/
This is a superficial problem, but it is necessary for beginners of git to mention it.
UseGit RM
To delete the file, and the delete operation record will be down;
UseRm
To delete a file. It only deletes a physical file and does not remove it from the GIT record.
Intuitively,Git RM
Delete the file and runGit commit-M "ABC"
When the file is submitted, the file deletion operation is automatically submitted.
ForRm
Command to directly delete the file, runGit commit-M "ABC"
When the file is submitted, the operation to delete the file is not submitted.
It doesn't matter, even if you already passRm
Delete an object, or useGit RM
Command to delete the file from the GIT record again.Git commit-M "ABC"
You can also submit the deletion operation later.
If you accidentally useRm
Command to delete a large number of files?
Yes.Git RM
Deleting a file one by one seems quite painful.
Fortunately, there are more convenient solutions. There is no problem if you submit them in the following way:Git commit-am "ABC"
Summary:
When deleting a file in a directory managed by git, you can record the deletion action in the following two ways:
I,Rm
+Git commit-am "ABC"
II,Git RM
+Git commit-M "ABC"
In addition,Git add.
Only added and modified actions can be recorded. The deletion action depends onGit RM
.
Finally,Rm
The deleted file is inNot staged
Status, that is, the status between "not modified" and "submitted.
Below is the test diagram
I,Git RM
AndRm
Differences
II,Git add.
Unable to recordRm
Delete action
III,Git commit-M "ABC"
Unable to submitRm
Delete action
IV,Git commit-am "ABC"
Role of parameter