2016-02-10 65 views
0

是否有任何方法可以在git bash會話中恢復所有本地刪除的文件? 我做了一個備份文件夾,但git與原始文件夾一起刪除它。在git bash會話中撤消所有本地進行的更改

我需要恢復在git rm -rf *命令之後列出的所有文件。 直到他們回來才能關閉我的電腦。

對不起長文本,但在下面我會顯示我嘗試在此會話中使用的所有命令。


[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git branch -D master 
git rm -rf *Deleted branch master (was d30697f). 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git checkout --orphan master 
Switched to a new branch 'master' 

[email protected] 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' 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ ^C 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git reset (--hard) HEAD~1 
bash: syntax error near unexpected token `(' 

[email protected] 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>...]' 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git reset 

[email protected] 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 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git reset --hard 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git reset --hard d30697f 
HEAD is now at d30697f updated 

[email protected] 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 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git checkout HEAD 

[email protected] 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 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git checkout -b newbranch 
Switched to a new branch 'newbranch' 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git reset -- Pokenizer/ 

[email protected] 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. 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git ls-files –deleted 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git reset HEAD 

[email protected] 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. 

[email protected] MINGW64 /c/xampp/htdocs/Git/Pokenizer (master|REBASE 1/3) 
$ git ls-files -d | xargs git checkout -- 

[email protected] 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 

回答

1

看起來你已經有了衝突從一開始就

衍合嘗試這些命令

git的變基--abort

的git的復位 - 硬頭

檢查日誌以查看您想要回滾到的提交

git的日誌--oneline --graph --decorate --all

+0

我嘗試的命令和得到這個輸出:'斯特凡@桌面97STV3T MINGW64/C/XAMPP/htdocs中/混帳/ Pokenizer(主| REBASE 1/3) $ GIT中變基--abort 斯蒂芬@ DESKTOP-97STV3T MINGW64/C/XAMPP/htdocs中/ GIT中/ Pokenizer(主) $ GIT中的復位 - 硬HEAD現在 頭處於d30697f更新 斯蒂芬@ DESKTOP-97STV3T MINGW64/c/xampp/htdocs/Git/Pokenizer(master) $ git log --oneline --graph --decorate --all * d30697f(HEAD - > master,origin/master)updated * bea5a92(newbranch)起來日 * b26bc2d更新 * 45cd901更新 * ab1d5f4添加項目文件 * 373e232更新README.md * 8cecd13笑 * a47ca75初始commit' –

+0

刪除所有我犯下的文件,之前,但我沒有看到犯日誌列表。 –