Git File Deletion operations

Source: Internet
Author: User

Git File Deletion operations

To delete a file using Git, you must use the Git rm command. Finally, git commit

Note that the rm command cannot be deleted directly. You can use the git status Command to try it. (The test file is created to demonstrate the difference between git rm and rm ):

19: 54: 51bkjia @~ /Documents/git/test> vi test
19: 55: 07bkjia @~ /Documents/git/test> ll
Total 16
-Rw-r --. 1 bkjia wang 2007 Apr 18 getZhihuDaily. py
-Rw-r --. 1 bkjia wang 22 Apr 18 07:02 README. md
-Rw-r --. 1 bkjia wang 5 Apr 30 :55 test
Drwxrwxr-x. 7 bkjia wang 86 Apr 20 06:08 vim-colors-solarized
-Rw-r --. 1 bkjia wang 1233 Apr 30 vimrc
19: 55: 09bkjia @~ /Documents/git/test> git add test
19: 55: 15bkjia @~ /Documents/git/test> git commit-m "test"
[Master 710da9d] test
1 file changed, 1 insertion (+)
Create mode 100644 test
19: 55: 24bkjia @~ /Documents/git/test> ls
GetZhihuDaily. py README. md test vim-colors-solarized vimrc
19: 55: 26bkjia @~ /Documents/git/test> git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (Use "git push" to publish your local commits)
#
# Untracked files:
# (Use "git add <file>..." to include in what will be committed)
#
# Vim-colors-solarized/
Nothing added to commit but untracked files present (use "git add" to track)
19: 55: 35bkjia @~ /Documents/git/test> rm test
19: 56: 30bkjia @~ /Documents/git/test> git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (Use "git push" to publish your local commits)
#
# Changes not staged for commit:
# (Use "git add/rm <file>..." to update what will be committed)
# (Use "git checkout -- <file>..." to discard changes in working directory)
#
# Deleted: test
#
# Untracked files:
# (Use "git add <file>..." to include in what will be committed)
#
# Vim-colors-solarized/
No changes added to commit (use "git add" and/or "git commit-")
19: 56: 33bkjia @~ /Documents/git/test> git rm test
Rm 'test'
19: 56: 41bkjia @~ /Documents/git/test> git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (Use "git push" to publish your local commits)
#
# Changes to be committed:
# (Use "git reset HEAD <file>..." to unstage)
#
# Deleted: test
#
# Untracked files:
# (Use "git add <file>..." to include in what will be committed)
#
# Vim-colors-solarized/
19: 56: 47bkjia @~ /Documents/git/test> git commit-m "rm test"
[Master 2953ea2] rm test
1 file changed, 1 deletion (-)
Delete mode 100644 test
19: 57: 00bkjia @~ /Documents/git/test> git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
# (Use "git push" to publish your local commits)
#
# Untracked files:
# (Use "git add <file>..." to include in what will be committed)
#
# Vim-colors-solarized/
Nothing added to commit but untracked files present (use "git add" to track)

GitHub Tutorials:

GitHub tutorials

Git tag management details

Git branch management

Git remote repository details

Git local Repository (Repository) Details

Git server setup and Client installation

Git Overview

Share practical GitHub tutorials

Git details: click here
Git: click here

This article permanently updates the link address:

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.