So my teammates had set up a git repository and all of us were supposed to push our own respective works to our own separate branch.
Difference is, everyone used the Desktop app while I tried to use the CLI to create a new empty branch and push to it but instead it deleted everything under my assets folder!!!!
I followed this to create an empty branch: Create empty branch on GitHub where in it says to use:
git switch --orphan <new branch>
which I did.
I initialised a new local git repository, set the remote origin, did the switch orphan command above, committed, and pushed. When I then went to check Github if the files are uploaded properly, I saw that it was only partially uploaded. Specifically, only the non-important files. I then got confused so I went back to check at my original files only to then find out that they're GONE.
Please somebody help.... That was a month's worth of tireless day to night work...
I'll include a log of the terminal here: https://gist.github.com/NicholasSebastian/b5dceb995e5a33922df8fbeb99f03652
CodePudding user response:
Ok after all that panicking, reading through a ton of git documentation and other blogs and sites revealed that I can list all changes on the git repository with:
git reflog
where it shows all the changes and its corresponding SHA reference values.
I can then use the git reset --hard
command to replace the current directory with the state it was at a given SHA reference point:
git reset --hard <SHA value>
I'm glad I finally got all my files back at least after all that panic and stress.
Lesson learned the hard way: Back up all your files.