On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: web/img/add-btn-bg.png
# deleted: web/img/add-tribute-button.png
# deleted: web/img/bottom-shadow.png
# deleted: web/img/database-line.png
# deleted: web/img/glyphicons-halflings-white.png
# deleted: web/img/glyphicons-halflings.png
# deleted: web/img/header-logo.png
# deleted: web/img/horizontal-line.png
# deleted: web/img/icons-btn.png
# deleted: web/img/icons.png
# deleted: web/img/line-bottom-menu.png
# deleted: web/img/never-forget.png
# deleted: web/img/tribute-icon-line.png
# deleted: web/img/uszatek.jpg
# deleted: web/img/uszatek_106.jpg
# deleted: web/img/uszatek_148.jpg
# deleted: web/img/uszatek_32.jpg
# deleted: web/img/uszatek_50.jpg
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: web/app_dev.php
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# img/
# randomNames.csv
# sampledb.tgz
# watch/
# web/assets/
# web/uploads/
我需要從「要提交的更改」返回文件。怎麼做?如何在git repo中意外刪除文件?
你真的讀過你發佈的內容嗎? Git告訴你你需要做什麼:**'(使用「git reset HEAD ...」來取消)'**然後**'(使用「git checkout- ...」來丟棄工作目錄中的變化)**。 –
meagar
我知道,但我寫了「git reset HEAD web/img/*」,但它沒有工作,所以我認爲我必須做其他事情。對不起.. – kspacja
如果你已經刪除了'web/img/*',運行'git reset HEAD web/img/*'將不會執行任何操作,因爲shell在調用之前試圖展開'web/img/*' 'git',失敗,因此傳遞字符串'web/img/*','git'會嘗試匹配文本文件名。這是一種痛苦,但是你必須爲每個單獨的文件運行'git reset HEAD web/imgadd-btn-bg.png'等等(或者解析'git status'來生成文件列表(類似' git reset HEAD $(git status | awk'/ deleted:/ {print $ NF}')'(not tested)。 – twalberg