Git刪除檔案操作,git刪除檔案

來源:互聯網
上載者:User

Git刪除檔案操作,git刪除檔案

使用Git刪除檔案需要使用Git rm命令來實現,最後git commit

需要注意的是直接rm命令刪除後是不可以的,可以用git status 命令嘗試一下,效果下(建立了test檔案,示範了git rm和rm的區別):

19:54:51wang@~/Documents/git/test >>  vi test 19:55:07wang@~/Documents/git/test >>  ll
total 16-rw-rw-r--. 1 wang wang 2007 Apr 18 07:02 getZhihuDaily.py-rw-rw-r--. 1 wang wang 22 Apr 18 07:02 README.md-rw-rw-r--. 1 wang wang 5 Apr 30 19:55 testdrwxrwxr-x. 7 wang wang 86 Apr 20 06:08 vim-colors-solarized-rw-rw-r--. 1 wang wang 1233 Apr 30 19:47 vimrc19:55:09wang@~/Documents/git/test >> git add test 19:55:15wang@~/Documents/git/test >> git commit -m "test" [master 710da9d] test 1 file changed, 1 insertion(+) create mode 100644 test
19:55:24wang@~/Documents/git/test >> ls getZhihuDaily.py README.md test vim-colors-solarized vimrc 19:55:26wang@~/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:35wang@~/Documents/git/test >> rm test 19:56:30wang@~/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 -a") 19:56:33wang@~/Documents/git/test >> git rm test rm 'test' 19:56:41wang@~/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:47wang@~/Documents/git/test >> git commit -m"rm test" [master 2953ea2] rm test 1 file changed, 1 deletion(-) delete mode 100644 test 19:57:00wang@~/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)

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.