When removing files from a Git repository I accidentally also removed a file that had uncommitted changes.
Reverting the Remove resulted in the file returning without the uncommitted changes. Is there any way of getting back the uncommitted state of the file?
Taking advice from jmort253 heres are the steps…
-
Made changes to file (it had previously been committed & pushed so
it is in git) -
Using SourceTree, removed some files accidentally
including the previously mentioned file. -
Pushed to origin
-
Having realised mistake reversed the commit (using SourceTree).
-
File is now back but it missing the changes made in step 1.
Hope that helps.
In short : no.
An uncommited file is (nearly by definition) a file the version control system does not know anything about, so the version control system will no more be able to help you as if you had deleted a random file on your disk (e.g. a file that had never been in the file hierarchy of your repository).
That is, unless you have a stash on a previous state of your repository that includes the uncommited changes ? (
git stash listshould give you an idea)If you don’t, you should turn to the file recovery methods appropriate for your operating system and filesystem.