標籤:github 刪除檔案 rm
刪除單個檔案
一般情況下,通常可直接在檔案管理工具中直接把檔案刪了,或者用rm命令刪了
$ rm README.txt
這個時候,工作區是刪除了,可版本庫還沒有。
git status命令會立刻告訴你哪些檔案被刪除了
$ git statusOn branch masterYour branch is up-to-date with ‘origin/master‘.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: README.txtno changes added to commit (use "git add" and/or "git commit -a")
現在有兩個選擇,一是確實要從版本庫中刪除該檔案,那就用命令
git rm刪掉,並且
commit,並且
push
$ git rm README.txtrm ‘README.txt‘$ git commit -m "remove README.txt"[master d17efd8] remove README.txt 1 file changed, 1 deletion(-) delete mode 100644 README.txt$ git push -u origin masterCounting objects: 3, done.Delta compression using up to 4 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (2/2), 210 bytes | 0 bytes/s, done.Total 2 (delta 1), reused 0 (delta 0)To [email protected]:itmyhome2013/mygithub.git 3c147ee..c01c174 master -> masterBranch master set up to track remote branch master from origin.
另一種情況是刪除了,因為版本庫裡還有呢,所以可以把誤刪的檔案恢複到最新版本
$ git checkout -- README.txt
刪除檔案夾
可先直接在檔案管理工具中把要刪除的檔案夾刪掉(以WEB-INF檔案夾為例)
$ git add --all$ git commit -m "remove WEB-INF"$ git push -u origin master
git add -A(--all):表示把所有tracked檔案中被修改過或已刪除檔案和所有untracted的檔案資訊添加到索引庫。
itmyhome
出處:http://blog.csdn.net/itmyhome1990/article/details/39672913
歡迎加入JAVA技術交流群:74955800
GitHub刪除檔案