1. 程式人生 > >GitHub刪除文件

GitHub刪除文件

blank 能夠 you branch rec with 普通 stat com

刪除單個文件


普通情況下,通常可直接在文件管理器中直接把文件刪了,或者用rm命令刪了

$ rm README.txt
這個時候,工作區是刪除了,可版本號庫還沒有。git status命令會立馬告訴你哪些文件被刪除了
$ git status
On branch master
Your 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.txt

no changes added to commit (use "git add" and/or "git commit -a")
如今有兩個選擇,一是確實要從版本號庫中刪除該文件。那就用命令git rm刪掉,而且commit。而且push
$ git rm README.txt
rm ‘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 master
Counting 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 -> master Branch 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


GitHub刪除文件