Accidentally Deleted my files #23731
-
The situtation I have right now is that I have a folder “Java” and inside I placed “Pokemon Arena” folder, which I wanted to turn into it’s own repo. I used this line of code, not knowing what I was doing… _ git filter-branch --prune-empty --subdirectory-filter Pokemon\ Arena\ nt/ master _ (master was also the name of my old branch, thinking i’ve rewrote the branch). I then proceeded to commit and force push, losing all of my java files. I’m new to github, would greatly appreciate the help and support :slight_smile: |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
I think you pretty much rewrote the entire Git history of your repo. However, the accepted answer here: https://stackoverflow.com/questions/14542326/undo-git-filter-branch mentions some kind of backup folder. I do reccommend that you first make a backup locally of the current state before executing more commands in order not to lose more things. |
Beta Was this translation helpful? Give feedback.
-
Would I use
To restore ? |
Beta Was this translation helpful? Give feedback.
-
I don’t know if it will work, however if you’ve copied the folder containing the repo locally you have nothing to lose. Be absolutely sure to have a copy of the repo folder! |
Beta Was this translation helpful? Give feedback.
-
Thank you for your help! It restored everything back to where it was. Lesson learned to always have back ups of my files ;D |
Beta Was this translation helpful? Give feedback.
-
Wow! I’m a git newb and found myself in the same position. When trying to commit and push changes I’d find that the new files I created were all gone. Literally a whole day’s worth of work down the drain. But the command you posted DID THE TRICK! Like magic, my files are back! Thank goodness!!! |
Beta Was this translation helpful? Give feedback.
-
I just about jumped off the roof literally when my 2 month old project was deleted after I reverted my initial commit. I was in the process of getting this project out to our Gitlab server and noticed that the commit had files I had in the gitignore but I guess I need to specify the full path. Any way I reverted the commit and then all my files went poof. So for those that are frantic, here is what I did: git reset --hard HEAD@{integer} In my case, integer was 0. Once I ran the command: ’ HEAD is now at a35df4a Initial commit All is good. I have just copied everything to my NAS:-) Not taking any chances. |
Beta Was this translation helpful? Give feedback.
-
thaaaaank you alextwo 👌👌 |
Beta Was this translation helpful? Give feedback.
I think you pretty much rewrote the entire Git history of your repo. However, the accepted answer here: https://stackoverflow.com/questions/14542326/undo-git-filter-branch mentions some kind of backup folder. I do reccommend that you first make a backup locally of the current state before executing more commands in order not to lose more things.