运行git rm--cached删除后无法恢复文件
在运行git rm--cached之后,我无法恢复意外删除的文件。我尝试了git重设和其他几种方法,但没有任何帮助运行git rm--cached删除后无法恢复文件,git,ubuntu,Git,Ubuntu,在运行git rm--cached之后,我无法恢复意外删除的文件。我尝试了git重设和其他几种方法,但没有任何帮助 [ec2-user@ip-10-0-0-190 cgsignlab]$ git rm --cached . fatal: not removing '.' recursively without -r You have new mail in /var/spool/mail/ec2-user [ec2-user@ip-10-0-0-190 cgsignlab]$ git rm --
[ec2-user@ip-10-0-0-190 cgsignlab]$ git rm --cached .
fatal: not removing '.' recursively without -r
You have new mail in /var/spool/mail/ec2-user
[ec2-user@ip-10-0-0-190 cgsignlab]$ git rm --cached . -r
error: 'vendor/apix/log' has staged content different from both the file and the HEAD
(use -f to force removal)
error: 'vendor/aws/aws-sdk-php' has staged content different from both the file and the HEAD
(use -f to force removal)
error: 'vendor/guzzlehttp/guzzle' has staged content different from both the file and the HEAD
(use -f to force removal)
error: 'vendor/guzzlehttp/promises' has staged content different from both the file and the HEAD
(use -f to force removal)
error: 'vendor/guzzlehttp/psr7' has staged content different from both the file and the HEAD
(use -f to force removal)
error: 'vendor/nategood/httpful' has staged content different from both the file and the HEAD
(use -f to force removal)
error: 'vendor/nicolab/php-ftp-client' has staged content different from both the file and the HEAD
(use -f to force removal)
error: 'vendor/psr/http-message' has staged content different from both the file and the HEAD
(use -f to force removal)
error: 'vendor/psr/log' has staged content different from both the file and the HEAD
(use -f to force removal)
[ec2-user@ip-10-0-0-190 cgsignlab]$ git reset HEAD .
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
[ec2-user@ip-10-0-0-190 cgsignlab]$ git status
# HEAD detached at 04e2948
nothing to commit, working directory clean
You have mail in /var/spool/mail/ec2-user
[ec2-user@ip-10-0-0-190 cgsignlab]$
[ec2-user@ip-10-0-0-190 cgsignlab]$git rm——缓存。
致命:不在没有-r的情况下递归删除“.”
您有了新的mail-in/var/spool/mail/ec2用户
[ec2-user@ip-10-0-0-190 cgsignlab]$git rm——缓存-R
错误:“vendor/apix/log”具有与文件和标头不同的暂存内容
(使用-f强制移除)
错误:“vendor/aws/aws sdk php”暂存的内容与文件和标头不同
(使用-f强制移除)
错误:“vendor/guzzlehttp/guzzle”暂存的内容与文件和头不同
(使用-f强制移除)
错误:“vendor/guzzlehttp/promises”已暂存与文件和标头不同的内容
(使用-f强制移除)
错误:“vendor/guzzlehttp/psr7”已暂存与文件和标头不同的内容
(使用-f强制移除)
错误:“vendor/nategood/httpful”已暂存与文件和标头不同的内容
(使用-f强制移除)
错误:“vendor/nicolab/php ftp client”暂存的内容与文件和标题不同
(使用-f强制移除)
错误:“供应商/psr/http消息”的暂存内容与文件和标头不同
(使用-f强制移除)
错误:“vendor/psr/log”具有与文件和标头不同的暂存内容
(使用-f强制移除)
[ec2-user@ip-10-0-0-190 cgsignlab]$git重置磁头。
致命:参数“HEAD”不明确:未知修订或路径不在工作树中。
使用“---”将路径与修订分开,如下所示:
'吉特[…]-[…]'
[ec2-user@ip-10-0-0-190 cgsignlab]$git状态
#头部在04e2948处分离
没有要提交的内容,正在清理目录
您有mail-in/var/spool/mail/ec2用户
[ec2-user@ip-10-0-0-190 cgsignlab]$
这些是我需要恢复的文件,非常感谢您的帮助
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: art.php
# new file: ceil.php
# new file: composer.json
# new file: composer.lock
# new file: metaupdate.php
# new file: movetoreview.php
# new file: orders.php
# new file: shipments.php
# new file: shipments/tracking.csv
# new file: src/CG/Aws/S3/Client.php
# new file: src/CG/OrderDesk/RestApi.php
# new file: src/CG/Orders/Order.php
# new file: src/CG/Orders/OrderDetails.php
# new file: src/CG/Orders/RestApi.php
# new file: src/CG/Orders/ShipMethods.php
# new file: src/CG/PitchPrint/RestApi.php
# new file: src/CG/Shipments/TrackingAdapter.php
# new file: src/CG/SignLab/ImageFormatter.php
# new file: src/CG/SignLab/Products.php
# new file: src/CG/SignLab/Utils.php
#要提交的更改:
#(使用“git rm--cached…”取消存储)
#
#新文件:art.php
#新文件:ceil.php
#新文件:composer.json
#新文件:composer.lock
#新文件:metaupdate.php
#新文件:movetoreview.php
#新文件:orders.php
#新文件:shippings.php
#新文件:Shippings/tracking.csv
#新文件:src/CG/Aws/S3/Client.php
#新文件:src/CG/OrderDesk/RestApi.php
#新文件:src/CG/Orders/Order.php
#新文件:src/CG/Orders/OrderDetails.php
#新文件:src/CG/Orders/RestApi.php
#新文件:src/CG/Orders/ShipMethods.php
#新文件:src/CG/PitchPrint/RestApi.php
#新文件:src/CG/shippings/TrackingAdapter.php
#新文件:src/CG/SignLab/ImageFormatter.php
#新文件:src/CG/SignLab/Products.php
#新文件:src/CG/SignLab/Utils.php
需要更多的评论,所以这不认为这是所有的代码,但需要张贴相关的日志
[ec2-user@ip-10-0-0-190 cgsignlab]$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: art.php
# new file: ceil.php
# new file: composer.json
# new file: composer.lock
# new file: metaupdate.php
# new file: movetoreview.php
# new file: orders.php
# new file: shipments.php
# new file: shipments/tracking.csv
# new file: src/CG/Aws/S3/Client.php
# new file: src/CG/OrderDesk/RestApi.php
# new file: src/CG/Orders/Order.php
# new file: src/CG/Orders/OrderDetails.php
# new file: src/CG/Orders/RestApi.php
# new file: src/CG/Orders/ShipMethods.php
# new file: src/CG/PitchPrint/RestApi.php
# new file: src/CG/Shipments/TrackingAdapter.php
# new file: src/CG/SignLab/ImageFormatter.php
# new file: src/CG/SignLab/Products.php
# new file: src/CG/SignLab/Utils.php
# new file: vendor/apix/log
# new file: vendor/autoload.php
# new file: vendor/automattic/woocommerce/.editorconfig
# new file: vendor/automattic/woocommerce/.gitignore
# new file: vendor/mtdowling/jmespath.php/tests/compliance/wildcard.json
# new file: vendor/nategood/httpful
# new file: vendor/nicolab/php-ftp-client
# new file: vendor/psr/http-message
# new file: vendor/psr/log
#
[ec2-user@ip-10-0-0-190 cgsignlab]$ git reset HEAD
[ec2-user@ip-10-0-0-190 cgsignlab]$git状态
#论分行行长
#
#初始提交
#
#要提交的更改:
#(使用“git rm--cached…”取消存储)
#
#新文件:art.php
#新文件:ceil.php
#新文件:composer.json
#新文件:composer.lock
#新文件:metaupdate.php
#新文件:movetoreview.php
#新文件:orders.php
#新文件:shippings.php
#新文件:Shippings/tracking.csv
#新文件:src/CG/Aws/S3/Client.php
#新文件:src/CG/OrderDesk/RestApi.php
#新文件:src/CG/Orders/Order.php
#新文件:src/CG/Orders/OrderDetails.php
#新文件:src/CG/Orders/RestApi.php
#新文件:src/CG/Orders/ShipMethods.php
#新文件:src/CG/PitchPrint/RestApi.php
#新文件:src/CG/shippings/TrackingAdapter.php
#新文件:src/CG/SignLab/ImageFormatter.php
#新文件:src/CG/SignLab/Products.php
#新文件:src/CG/SignLab/Utils.php
#新文件:vendor/apix/log
#新文件:vendor/autoload.php
#新文件:vendor/automatic/woocommerce/.editorconfig
#新文件:vendor/automatic/woocommerce/.gitignore
#新文件:vendor/mtdowling/jmespath.php/tests/compliance/wildcard.json
#新文件:vendor/nategood/httpful
#新文件:vendor/nicolab/php ftp客户端
#新文件:vendor/psr/http消息
#新文件:vendor/psr/log
#
[ec2-user@ip-10-0-0-190 cgsignlab]$git重置磁头
git fsck
在这里可能会有所帮助:
git fsck --unreachable
这将输出散列列表(可能比您删除的列表多得多)。然后使用这些散列来获取其内容:
git cat-file -p <hash>
git cat文件-p
不幸的是,您无法获取文件名,只能获取其内容。
git fsck
在这里可能会有所帮助:
git fsck --unreachable
这将输出散列列表(可能比您删除的列表多得多)。然后使用这些散列来获取其内容:
git cat-file -p <hash>
git cat文件-p
不幸的是,你不能得到文件名,只能得到它的内容。被删除的文件是否提交到git?它们在试图修复时被删除了?我只能在master new git innit directoryTry
git checkout上提交一次。
。这个命令应该将文件“还原”到git中的任何位置。如果您有未老化的更改,请不要执行此操作。git checkout。不还原已删除的文件,我不敢相信没有警告说git将删除所有这些文件。如果git从未跟踪这些文件,则无法使用git还原它们。您需要找到另一个工具来执行此操作。被删除的文件是否提交到git?它们在尝试修复时被删除了?我只在master new git innit directoryTrygit checkout上提交了一次。
。这个命令应该将文件“还原”到git中的任何位置。如果您有未老化的更改,请不要执行此操作。git checkout。不还原已删除的文件,我不敢相信没有警告说git将删除所有这些文件,如果这些文件从未被删除