We all have been there… For the beginner it’s easy to mess things up. What are your horror stories with Git?

Link to xkcd

  • nous@programming.dev
    link
    fedilink
    English
    arrow-up
    13
    ·
    edit-2
    1 year ago

    The first place I worked, when I joined they were using git for their developers. That is - a bare git repo on a server that everyone has a key on so they can pull over ssh. No web UI at all.


    The product was originally evolved from a 3rd party code base that was a all in one thing - backend and frontend together in the repo. But the company wanted their own UI so they created a new git repo for it to keep it isolated and decoupled. You know, so development and deployments were easier. But when I joined the two code bases were so intertwined the UI would not work if you did not have the backend checked out into the same location as the UI. No submodules, no dependencies coded anywhere - you just had to checkout both repos side by side to get it to work.


    There was also this critical bit of software we had - developed by one guy in C (a language no one else really know). Now this was not a very complex application, but every billable event that we had went through it - so critical for us to be able to do anything. Its development process was, the guy would login to one of the production servers, change the code, rebuilt it and test it live on that server. Then when he was happy he would get a sysadmin to copy the code and rebuild it to all other nodes (this could be to over 2500 servers mind you). Ok, so this one was more horrifying due to the lack of any version control at all - though at least the code was backed up to a lot of servers…

    Eventually I was tasked with getting that codebase in git and making it so we could rebuild it outside of production. This was a nightmare - had to learn how autotools worked in far more detail then I ever wanted only to find out the original developer had manually hand crafted some auto generated files.


    Years later (after the company had good git practices and we had fixed all the issues above), this developer was working on a new project. Once I found out about it I took a look. He was using git this time. But the development process was, ssh to a prod server, edit the code live. Then wait for a cron job to run that dumped a bunch of store procedures from the database to the project, add all files, commit and push the code. I honestly don’t know how anyone could get a standard workflow completely backwards…


    On a nicer note, I have one about this one time git actually saved me weeks of work by accident. In uni I was working on some coursework - this was back when I was learning git and still trying to figure-out how best to use it. I was not using it correctly yet - for one I was not pushing code up to a remote yet, just working locally on my system. Well, one day I was doing some development and needed to clear out my build directory as I was seeing some weird behaviour. I switched over to the terminal that I keep inside that build dir and do a rm -rf *. Something I had done many times before to clear it out. But this time, I was in the wrong location, I was in the project root. And that was it, all my code was gone, weeks worth of work down the drain.

    But then I noticed a .git folder still there. Turns out * does not expand hidden files. So a git checkout . and I managed to restore all files from my last commit - which was only a couple of hours ago. I don’t think I had ever been so relieved before. I quickly pushed up that code to a remote repo.