Sweet Baby Jesus I love GIT
5:42 PMPier78Woops I actually wrote this back in March but I forgot to publish it.
So today I realized I didn't do just one stupid thing, but TWO. I've been working on an assignment and realized I liked my older implementation for a module in my program better so I decided to go back to the original .c file. However when checking out the past commits, I noticed the .c file was not changing. When checking for changed lines, the diff came up empty. I was baffled and thought my git repo blew up or something. Maybe I messed up some symbolic links? I moved the .c file around and backed it up. After going through my git commit history more thoroughly,...ARE YOU @#%& kidding me??. I forgot to stage that file to be tracked the entire time I had worked on the assignment. Holy crap. Instead I had staged the executable instead of the C file..
I ended up deleting the backup files but without thinking. (I also unknowingly moved both the back up and the original C file to the same directory and used rm -r to throw away the directory). Stupidly while I was flustered, I had also committed the change (file deletions) and deleted the test branch. So now I didn't the old version of my implementation OR the new one ~_~. Luckily you can recover deleted branches.
I was able to recover the .c file since git keeps track of past deleted branches (no--not thank God, Thank LINUS). I was able to use git reflog to get the SHA ID and use git checkout SHA_HERE to recover the old branch and recover the .c file(s).
0 comments