Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get back the changes after accidental checkout?

The following was the status of my repo.

[~/rails_apps/jekyll_apps/nepalonrails (design)⚡] ➔ gst # On branch design # Changed but not updated: #   (use "git add/rm <file>..." to update what will be committed) #   (use "git checkout -- <file>..." to discard changes in working directory) # #   modified:   _layouts/default.html #   deleted:    _site/blog/2010/04/07/welcome-to-niraj-blog/index.html #   deleted:    _site/blog/2010/04/08/the-code-syntax-highlight/index.html #   deleted:    _site/blog/2010/05/01/showing-demo-to-kalyan/index.html #   deleted:    _site/config.ru #   deleted:    _site/index.html #   deleted:    _site/static/css/style.css #   deleted:    _site/static/css/syntax.css #   modified:   static/css/style.css # no changes added to commit (use "git add" and/or "git commit -a") 

Accedently, I did git checkout -f and now the changes are gone which I wasnt supposed to do.

[~/rails_apps/jekyll_apps/nepalonrails (design)⚡] ➔ git co -f [~/rails_apps/jekyll_apps/nepalonrails (design)] ➔ gst # On branch design nothing to commit (working directory clean) [~/rails_apps/jekyll_apps/nepalonrails (design)] ➔  

Can I get back the changes back?

like image 1000
Autodidact Avatar asked Jun 02 '10 20:06

Autodidact


People also ask

Can you undo git checkout?

The git reset , git checkout , and git revert commands are some of the most useful tools in your Git toolbox. They all let you undo some kind of change in your repository, and the first two commands can be used to manipulate either commits or individual files.

What happens when you force checkout?

Force a Checkout You can pass the -f or --force option with the git checkout command to force Git to switch branches, even if you have un-staged changes (in other words, the index of the working tree differs from HEAD ). Basically, it can be used to throw away local changes.


1 Answers

Another thing you can look at is through your IDE. I accidentally checkout 2 files and was able to bring back the changes through the 'local history' of my IDE (netbeans). What a blessing!

like image 59
gigi2 Avatar answered Nov 16 '22 01:11

gigi2