GitHub刪除檔案

來源:互聯網
上載者:User

標籤: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刪除檔案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.