I fear I already know the answer but I have try anyway…
I believe I accidentally clicked “Discard All Changes” in Source Control in VS Code while I was trying to figure out how to upload my code into GitHub. Now my code looks like this below.
Additionally, the folders that contained all my commands and subsystems are empty in my WPILIB project folder as if as if nothing was there in there in the first place. I also, looked in my recycle bin to find out if anything was in there as well. Nothing.
I had done some research already and I learned that I also screwed up by having not done any commits. So I am already trying my best to remake the code however I am wondering if there is anything I could salvage in order to lessen the work I will have to do? Thank you so much and good luck to you all!
If you still have the .class files then there’s hope, but not a guarantee.
First, create a new WPIlib project in a different folder.
Now, you’ll need to put each .class file (or the .jar if you have it) into a Java decompiler. I gave this one a quick check and it looks like it’ll do what you want, but you’ll lose comments.
Save each resulting files in the src folder of the new project. Make sure that they’re all in a folder structure similar to the original. (If you did the jar file, only include the files that you actually wrote and not all the wpilib files)
At this point, immediately make sure it builds, and then commit. In addition, you should push it to a remote repository (github, for instance) to avoid losing work again.
Now you can continue adding comments back in and implementing new features. I highly recommend committing often and pushing regularly. Git doesn’t track all changes, it only tracks the specific changes that you commit and push.
Feel free to reach out with any git questions! Good luck, I hope this helps you.
I want to thank you again for your help! I was able to finish copying all of the code that was lost and I am using Git to make sure I have copies of my code.
However, I am having a problem with Git syncing properly. Below is an error I’m getting when I’m trying to sync up the repository. This is the first time I am experiencing this error, before today VSCode and Github were syncing up properly as far as I know. Any help would be appreciated thank you!
So the command git pull --tags origin Home-PC will attempt to pull the reference (branch or tag) Home-PC from the remote named origin, and update your current branch to include it. It will also pull all tags and make a local copy of them (the --tags part).
If you’re trying to move code from another location/repo/server, then you’re “pulling” the code to your local version. If you’re trying to send it from your local repo to a remote location, then you’re “pushing”. Which action are you trying to take?
If you’re trying to pull, then you should run git pull on its own, or maybe git pull origin master if that fails. (If your main branch is named main instead of master then use that instead).
If you’re trying to push, then you need git push origin master (again substituting main as needed). That will send your master branch up to the server.