有没有办法在git bash会话中恢复所有本地删除的文件? 我制作了一个备份文件夹,但是git将它与原始文件夹一起删除了。
我需要恢复git rm -rf *
命令后列出的所有文件。
在他们回来之前无法关闭我的电脑。
对于长文本感到抱歉,但在下面我将展示我尝试在此会话中使用的所有命令。
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git branch -D master
git rm -rf *Deleted branch master (was d30697f).
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git checkout --orphan master
Switched to a new branch 'master'
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git rm -rf *
rm 'README.md'
rm 'bootstrap/css/bootstrap-theme.css'
rm 'bootstrap/css/bootstrap-theme.css.map'
rm 'bootstrap/css/bootstrap-theme.min.css'
rm 'bootstrap/css/bootstrap.css'
rm 'bootstrap/css/bootstrap.css.map'
rm 'bootstrap/css/bootstrap.min.css'
rm 'bootstrap/fonts/glyphicons-halflings-regular.eot'
rm 'bootstrap/fonts/glyphicons-halflings-regular.svg'
rm 'bootstrap/fonts/glyphicons-halflings-regular.ttf'
rm 'bootstrap/fonts/glyphicons-halflings-regular.woff'
rm 'bootstrap/fonts/glyphicons-halflings-regular.woff2'
rm 'bootstrap/js/bootstrap.js'
rm 'bootstrap/js/bootstrap.min.js'
rm 'bootstrap/js/npm.js'
rm 'core/.DS_Store'
rm 'core/._.DS_Store'
rm 'core/ajax/ajax_handler.php'
rm 'core/classes/.DS_Store'
rm 'core/classes/._.DS_Store'
rm 'core/classes/Config.php'
rm 'core/classes/Cookie.php'
rm 'core/classes/Data.php'
rm 'core/classes/Database.php'
rm 'core/classes/Hash.php'
rm 'core/classes/Input.php'
rm 'core/classes/Redirect.php'
rm 'core/classes/Session.php'
rm 'core/classes/Token.php'
rm 'core/classes/Transformer.php'
rm 'core/classes/User.php'
rm 'core/classes/Validate.php'
rm 'core/functions/.DS_Store'
rm 'core/functions/._.DS_Store'
rm 'core/functions/login.php'
rm 'core/functions/register.php'
rm 'core/functions/sanitize.php'
rm 'core/init.php'
rm 'favicon.ico'
rm 'fontello/LICENSE.txt'
rm 'fontello/README.txt'
rm 'fontello/config.json'
rm 'fontello/css/animation.css'
rm 'fontello/css/fontello-codes.css'
rm 'fontello/css/fontello-embedded.css'
rm 'fontello/css/fontello-ie7-codes.css'
rm 'fontello/css/fontello-ie7.css'
rm 'fontello/css/fontello.css'
rm 'fontello/demo.html'
rm 'fontello/font/fontello.eot'
rm 'fontello/font/fontello.svg'
rm 'fontello/font/fontello.ttf'
rm 'fontello/font/fontello.woff'
rm 'images/006-mega-x.gif'
rm 'images/MegaGlurakX.jpg'
rm 'images/Pokeball.png'
rm 'index.php'
rm 'info.txt'
rm 'javaScripts/main.js'
rm 'logout.php'
rm 'pokenizer.sql'
rm 'slices/base/body_end.inc.php'
rm 'slices/base/body_start.inc.php'
rm 'slices/base/head.inc.php'
rm 'slices/base/html_end.inc.php'
rm 'slices/base/html_start.inc.php'
rm 'slices/base/page_end.inc.php'
rm 'slices/base/page_start.inc.php'
rm 'slices/modals/front/login_modal.inc.php'
rm 'slices/modals/front/signup_modal.inc.php'
rm 'slices/sites/start.php'
rm 'slices/sites/user.php'
rm 'slices/tests/profile.php'
rm 'slices/tests/start.php'
rm 'slices/widgets/front/heading.inc.php'
rm 'slices/widgets/front/navbar.inc.php'
rm 'slices/widgets/front/panels.inc.php'
rm 'slices/widgets/front/welcome.inc.php'
rm 'slices/widgets/loggedIn/header_options.inc.php'
rm 'slices/widgets/loggedIn/left_sidebar.inc.php'
rm 'slices/widgets/loggedOut/left_sidebar.inc.php'
rm 'styleSheets/activities.css'
rm 'styleSheets/contentArea/main.css'
rm 'styleSheets/front/main.css'
rm 'styleSheets/predefinitions.css'
rm 'styleSheets/profile.css'
rm 'users/0f2586f30af8a59f3fe278efc41f16f2/profile.jpg'
rm 'users/0f2586f30af8a59f3fe278efc41f16f2/profileFull.jpg'
rm 'users/36d38ab6c36f095dff785cf531e67ce4/profile.jpg'
rm 'users/36d38ab6c36f095dff785cf531e67ce4/profileFull.jpg'
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ ^C
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git reset (--hard) HEAD~1
bash: syntax error near unexpected token `('
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git reset --hard HEAD~1
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git reset
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git checkout --$(git ls-files -d)
fatal: You are on a branch yet to be born
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git reset --hard
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git reset --hard d30697f
HEAD is now at d30697f updated
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git checkout HEAD C:\xampp\htdocs\Git\Pokenizer
fatal: C:xampphtdocsGitPokenizer: 'C:xampphtdocsGitPokenizer' is outside repository
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git checkout HEAD
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git checkout HEAD^
Note: checking out 'HEAD^'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at bea5a92... updated
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git checkout -b newbranch
Switched to a new branch 'newbranch'
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git reset -- Pokenizer/
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git checkout -- Pokenizer/
error: pathspec 'Pokenizer/' did not match any file(s) known to git.
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git ls-files –deleted
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git reset HEAD
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git checkout -- lib bin
error: pathspec 'lib' did not match any file(s) known to git.
error: pathspec 'bin' did not match any file(s) known to git.
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git ls-files -d | xargs git checkout --
Stefan@DESKTOP-97STV3T MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3)
$ git ls-files -d | xargs git checkout -
Note: checking out 'bea5a92f5d9dca86ce34149c0ae9ba9eb42fd25a'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at bea5a92... updated
答案 0 :(得分:1)
看起来你从一开始就与rebase发生了冲突
尝试这些命令
git rebase --abort
git reset --hard HEAD
检查日志以查看您要回滚的提交
git log --oneline --graph --decorate --all