linux的git如何删除文件夹,Git删除文件操作

使用Git删除文件需要使用Git rm命令来实现,最后git commit

需要注意的是直接rm命令删除后是不可以的,可以用git status 命令尝试一下,效果如图下(创建了test文件,演示了git rm和rm的区别):

19:54:51linuxidc@~/Documents/git/test >>  vi test

19:55:07linuxidc@~/Documents/git/test >>  ll

total 16

-rw-rw-r--. 1 linuxidc wang 2007 Apr 18 07:02 getZhihuDaily.py

-rw-rw-r--. 1 linuxidc wang  22 Apr 18 07:02 README.md

-rw-rw-r--. 1 linuxidc wang    5 Apr 30 19:55 test

drwxrwxr-x. 7 linuxidc wang  86 Apr 20 06:08 vim-colors-solarized

-rw-rw-r--. 1 linuxidc wang 1233 Apr 30 19:47 vimrc

19:55:09linuxidc@~/Documents/git/test >>  git add test

19:55:15linuxidc@~/Documents/git/test >>  git commit -m "test"

[master 710da9d] test

1 file changed, 1 insertion(+)

create mode 100644 test

19:55:24linuxidc@~/Documents/git/test >>  ls

getZhihuDaily.py  README.md  test  vim-colors-solarized  vimrc

19:55:26linuxidc@~/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 ..." 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:35linuxidc@~/Documents/git/test >>  rm test

19:56:30linuxidc@~/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 ..." to update what will be committed)

#  (use "git checkout -- ..." to discard changes in working directory)

#

#      deleted:    test

#

# Untracked files:

#  (use "git add ..." to include in what will be committed)

#

#      vim-colors-solarized/

no changes added to commit (use "git add" and/or "git commit -a")

19:56:33linuxidc@~/Documents/git/test >>  git rm test

rm 'test'

19:56:41linuxidc@~/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 ..." to unstage)

#

#      deleted:    test

#

# Untracked files:

#  (use "git add ..." to include in what will be committed)

#

#      vim-colors-solarized/

19:56:47linuxidc@~/Documents/git/test >>  git commit -m"rm test"

[master 2953ea2] rm test

1 file changed, 1 deletion(-)

delete mode 100644 test

19:57:00linuxidc@~/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 ..." to include in what will be committed)

#

#      vim-colors-solarized/

nothing added to commit but untracked files present (use "git add" to track)

GitHub 教程系列文章:

Git 的详细介绍:请点这里

Git 的下载地址:请点这里

0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值