0

I had some untracked files in my branch A. I forgot to add and commit those changes and did git push -u origin/A. After that I checked out branch B and did git reset --hard origin/B. After doing these steps all the changes were lost in branch A. Is there any way to recover those changes/untracked files?

tejal567
  • 109
  • 1
  • 11
  • Unfortunately, no. – iBug Dec 27 '18 at 14:51
  • also check https://stackoverflow.com/questions/7147680/accidentally-reverted-to-master-lost-uncommitted-changes – Alireza Dec 27 '18 at 15:51
  • Possible duplicate of [After reset --hard all my untracked files are gone](https://stackoverflow.com/questions/52042030/after-reset-hard-all-my-untracked-files-are-gone) – phd Dec 27 '18 at 17:34
  • https://stackoverflow.com/search?q=%5Bgit%5D+recover+untracked+files+hard+reset – phd Dec 27 '18 at 17:34
  • 2
    Git is not going to help you here, it does not know about files until you add them. Your IDE may save you, many of them have local history. `git reset --hard` is one of the few dangerous git commands, don't included it in your workflow. In this case you could have used `git checkout -B origin/B` – Federico Nafria Dec 28 '18 at 11:09

0 Answers0