Differences between "Git RM" and "RM" (reprinted)

Source: Internet
Author: User

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 RMTo delete the file, and the delete operation record will be down;
UseRmTo delete a file. It only deletes a physical file and does not remove it from the GIT record.

Intuitively,Git RMDelete the file and runGit commit-M "ABC"When the file is submitted, the file deletion operation is automatically submitted.

ForRmCommand 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 passRmDelete an object, or useGit RMCommand to delete the file from the GIT record again.Git commit-M "ABC"You can also submit the deletion operation later.

If you accidentally useRmCommand to delete a large number of files?
Yes.Git RMDeleting 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,RmThe deleted file is inNot stagedStatus, that is, the status between "not modified" and "submitted.

Below is the test diagram

I,Git RMAndRmDifferences

II,Git add.Unable to recordRmDelete action

III,Git commit-M "ABC"Unable to submitRmDelete action

IV,Git commit-am "ABC"Role of parameter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.