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?
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.
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.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With