4 ms·
I could spend hours of my workday on some uninteresting, irrelevant bullshit because the local repo is fucked, or just delete it and move on to solving actual p
by jimmaswell 2y ago
I could spend hours of my workday on some uninteresting, irrelevant bullshit because the local repo is fucked, or just delete it and move on to solving actual problems and producing value. The choice is clear.
- Zambyte 2y agoOr you could spend an hour or so learning to use git (or a git compatible vcs like Jujutsu) and then you never bork your repos, and instead spend your time solving actual problems and producing value. What kind of pastries do you like?
- jimmaswell 2y agoI can't remember the last time I had to delete a repo, at most I do a hard reset to the head of the main branch. Still don't care and I'm doing well enough getting consistent maximum performance ratings at my job and building things in my own time. Sometimes a problem is not worth addressing, and part of being an effective software engineer on the whole is recognizing those times.
- jenadine 2y agoBoth points are valid. But it shouldn't take hours to "fix" a repo in most cases. As you said: git reset. Anyway, I've been putting some of my repo in very bad states by doing git operation from different unix user that lacked the right permission to do all the writes leaving some corrupted objects and stuff which needs a bit more than just a reset to recover. Then it takes some time to recover, but that's because I also don't want to loose some hours of un-pushed work. Doing a delete of my repo could have been faster but I'd have lost some temporary branches and squashes and stuff that would also represent some work. But I think the original point is for people who are not even able to do a git reset.
- matrss 2y agoSo, contrary to your own point, you did indeed put in some time and learned one of the ways you can fix a "fucked" repo, because it is more convenient to just 'git reset --hard main' than to delete and re-clone. There are some simple next steps to go from there: - notice that you don't have to reset to the main branch, you can put in any branch name - it doesn't even have to be a branch name, it can be any kind of reference to a commit - 'git reflog' is useful to find out a reference to a commit you recently were on, that you can then give to reset - you don't have to use --hard, I personally like using --keep, and sometimes you might want to keep local changes so you don't supply those options at all - ... What you already did is what Zambyte suggested you should do. Of course there is diminishing returns at some point, but that point comes way after 'git commit -am $msg && git push'.
- skeeter2020 2y ago>> Or you could spend an hour or so learning to use git This is such nonsense. The git you can learn in an hour gets you exactly to the point where you end up in this "now what?" situation. Furthermore unless you're working through this more regularly than every 6+ months you're not going to remember how to fix it.
- Zambyte 2y ago> Furthermore unless you're working through this more regularly than every 6+ months you're not going to remember how to fix it. Take notes.
- usr1106 2y agoI have never deleted a repo because it's messed up. In the early days understanding what was wrong was sometimes challenging. But once I learned it it's just routine to clean it up. I do occasionally search stuff from my reflog or trial branches from years ago, no way I want to lose that opportunity. One needs to learn full branch names and how the abbreviations used in daily life really work. A local branch called origin/foo can be confusing, especially after being pushed. And of course one needs to understanding the concept of remote branches in the first place, they are not really remote, typical poor git terminology. For mass mess-ups in the work tree git status -s | grep ... oneliners are your friend.
- matheusmoreira 2y agoOr you could actually learn git once and enjoy using a powerful tool without experiencing any of this friction. If you understand git you'll just know what to do when some weird thing happens.