this post was submitted on 03 Jul 2025
116 points (94.6% liked)

Programmer Humor

37024 readers
64 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

As the title says. I put the wrong value inside a clean up code and I wiped everything. I did not push any important work. I just want to cry but at least I can offer it to you.

Do not hesitate to push even if your project is in a broken state.

top 50 comments
sorted by: hot top controversial new old
[–] mormegil@programming.dev 1 points 2 hours ago

I wanted to publish a tiny utility I created to GitHub (you know, it might be useful to someone else...). Before that, I wanted to some cleanup, rebasing/squashing a bit, etc. In the middle of that:

$ git checkout featurebranch
The following untracked working tree files would be overwritten by checkout:
.gitignore
.idea/…
etc...

Oh, sure, no problem…

$ rm -rf * .*
$ git checkout featurebranch
fatal: not a git repository (or any of the parent directories): .git

D’oh! (Never mind, it probably wouldn't have been useful to anyone else, anyway.)

[–] theherk@lemmy.world 6 points 1 day ago

Some wisdom my dad shared with me decades ago: when you’ve lost everything and must rebuild, the rebuild is ALWAYS better. As a programmer for a very long time who has done what you did, I have found this to be true. So there is your silver lining.

[–] DrunkAnRoot@sh.itjust.works 2 points 1 day ago

i deleted all my nginx configs today its gonna be ok

[–] umbrella@lemmy.ml 5 points 2 days ago (2 children)

i sudo shutdown now the main production (remote) server a few times before, and ive been doing sshing into servers for a long time.

there there 🫂 its ok. we all do this shit. you do have backups of course, right?

you do have backups of course, right?

cries

[–] Fenrisulfir@lemmy.ca 3 points 1 day ago (1 children)

You’ve done it a few times? At the same job? Are you self-employed?

[–] umbrella@lemmy.ml 2 points 1 day ago* (last edited 1 day ago)

throughout a few years.

[–] LovableSidekick@lemmy.world 34 points 3 days ago (4 children)
IN CASE OF FIRE

1. git commit
2. git push
3. exit building
[–] 18107@aussie.zone 27 points 2 days ago* (last edited 2 days ago)

git-fire

"git-fire is a Git plugin that helps in the event of an emergency by switching to the repository's root directory, adding all current files, committing, and pushing commits and all stashes to a new branch (to prevent merge conflicts)."

[–] 69420@lemmy.world 6 points 2 days ago (2 children)

Except when everyone pushes to main at the same time and now you have conflicts.

[–] LovableSidekick@lemmy.world 4 points 1 day ago

They wouldn't push to main at the same time tho, they would push to the branches they're working on. Unless their organization is very badly run, and then it's probably already happened before just because it was Tuesday.

[–] RichieRich@lemmy.world 6 points 2 days ago (1 children)

Who pushes to main? That branch should be protected! Who reviews the merge request?

[–] 69420@lemmy.world 4 points 2 days ago

Lol, standards 🙄

[–] billwashere@lemmy.world 6 points 2 days ago (1 children)

I have this printed on a sign at work.

[–] LovableSidekick@lemmy.world 3 points 1 day ago

It was on a sign where I once worked, but that was almost 10 years ago.

[–] bhamlin@lemmy.world 5 points 2 days ago
  1. git commit -m 'asdf'
[–] mhzawadi@lemmy.horwood.cloud 54 points 3 days ago (1 children)

git commit, git push, git out

[–] MSBBritain@lemmy.world 10 points 3 days ago

I need a t-shirt that says this.

This is a programmers mic drop.

[–] wheezy@lemmy.ml 9 points 2 days ago* (last edited 2 days ago) (1 children)

I did a "rm -rf *" in the wrong directory today.

I got the absolutely beautiful "argument list too long" in return.

I had a backup. But holy shit I'm glad the directory had thousands of files in it and nothing happened. First time I got that bash error and was happy.

I usually have rm aliased to "trash" or whatever that cli based recycle bin is. But just installed a new OS and ran this on a NAS folder today by mistake.

My dad once rm -rf’ed his company’s payroll server by accident. He was a database admin at the time. He was asked to make a quick update to something. Instead of running it as a transaction (which would have been reversible) he went “eh it’s a simple update.” He hit Enter after typing out the change for the one entry, and saw “26478 entries updated”. At that point, his stomach fell out of his asshole.

The company was too cheap to commit to regular 3-2-1 backups, so the most recent backup he had was a manual quarterly backup from three months ago. Luckily, Payroll still had paper timesheets for the past month, so they were able to stick an intern on data entry and get people paid. So they just had a void for those two months in between the backup and the paper timesheets.

It wasn’t a huge issue, except for the fact that one of their employees was on parole. The parole officer asked the company to prove that the employee was working when he said he was. The officer wanted records for, you guessed it, the past three months. At that point, the company had to publicly admit to the fuckup. My dad was asked to resign… But at least the company started funding regular 3-2-1 backups (right before his two week notice was up.)

[–] einkorn@feddit.org 41 points 3 days ago

No backup, no mercy.

[–] rolling_resistance@lemmy.world 13 points 3 days ago (2 children)

Sorry this happened.

Use it as an opportunity to learn how to better store and edit your code (e.g. a VCS and a smart-ish editor). For me, a simple Ctrl-Z would be enough to get my code back.

[–] ftbd@feddit.org 1 points 2 days ago

it sounds like they rm -rf-ed their project. How would Ctrl+Z help here?

[–] mat@jlai.lu 1 points 2 days ago

I should have put it inside the post text but I used a wrong value inside a test

[–] Valmond@lemmy.world 16 points 3 days ago (1 children)

Ya, push push push baby, do it on your own branch so that you can find your way back if needed.

Especially when refactoring.

[–] ravermeister@lemmy.rimkus.it 4 points 3 days ago* (last edited 3 days ago)

I always like to say "push it to the limit" and then I have this homer Simpson with muscle body sitting on his super couch (I forgot which TV series the Simpsons made Satire of) picture in my head 🤣

Update, hah found it😁 https://m.youtube.com/watch?v=7Mhb9D35pkc&pp=ygUdc2ltcHNvbnMgcHVzaCBpdCB0byB0aGUgbGltaXQ%3D

[–] PeriodicallyPedantic@lemmy.ca 12 points 3 days ago

Sympathy upvote

[–] HelloRoot@lemy.lol 5 points 3 days ago (1 children)

You guys don't use a COW (copy on write) filesystem?

[–] lauha@lemmy.world 10 points 3 days ago (2 children)

Version control would be quite adequate if using a sane amount of time between pushes

[–] sxan@midwest.social 6 points 2 days ago

Except that one is automatically versioned and would have saved you this pain, and the other relies on you actively remembering to reflexively commit, and then do extra work to clean up your history before sharing, and once you push, it's harder to change history and make a clean version to share.

These days, there's little excuse to not use COW with automated snapshots in addition to your normal, manual, VCS activities.

[–] HelloRoot@lemy.lol 3 points 3 days ago* (last edited 3 days ago)

I'm paranoid. I have like 5 different ways (including 3-2-1 backups) to restore everything. COW fs is great for stuff that is not a git-able project.

[–] meme_historian@lemmy.dbzer0.com 7 points 3 days ago (1 children)

Do you at least have some local commits to get back to? Or did your job remove the .git folder as well? 👀

[–] mat@jlai.lu 8 points 3 days ago (5 children)
[–] MyNameIsRichard@lemmy.ml 3 points 3 days ago

You have backups? Right?

load more comments (4 replies)
[–] tias@discuss.tchncs.de 6 points 3 days ago (2 children)

I keep my git clone in Dropbox so I can revert accidental delete and always have the most recent code on all devices without having to remember to commit and push. If it requires manual execution I wouldn't really consider it a proper backup solution.

[–] dave@feddit.uk 2 points 2 days ago

I have been burnt by Dropbox in the past so now use Syncthing between my desktop, laptop, and a private remote server with file versioning turned on. Trivial to global ignore node_modules, and not giving data to a third party.

It's saved me on several occasions.

load more comments (1 replies)
[–] Cratermaker@discuss.tchncs.de 5 points 3 days ago

If you're using vscode you might be able to look through the individual file histories to recover some work.

[–] fibojoly@sh.itjust.works 4 points 3 days ago (1 children)

What did you learn from this?

[–] mat@jlai.lu 2 points 2 days ago* (last edited 2 days ago)

To push daily and to not write test :P

[–] Vince@lemmy.world 5 points 3 days ago (1 children)

Oh man, I hate losing code. Last time it happened I spent more time trying to recover it than it would've taken to rewrite it.

[–] victorz@lemmy.world 3 points 3 days ago (1 children)

You can't just... replace your baby, man!

[–] mormegil@programming.dev 1 points 2 hours ago

On the contrary! I found out that a rewrite from scratch leads to much better code and abstractions, as you understand the problem space better. (On the other hand, beware of http://catb.org/jargon/html/S/second-system-effect.html)

[–] lefaucet@slrpnk.net 4 points 3 days ago
[–] some_guy@lemmy.sdf.org 2 points 2 days ago

Time to implement a couple forms of backups.

[–] Mist101@lemmy.world 3 points 3 days ago

I have a separate usb harddrive for just this occasion. My lazy ass just likes to play "We backed it up last time, do we need to do it every time?

[–] anti_antidote@lemmy.zip 2 points 3 days ago

Sounds like you need Jujutsu 🥰

[–] Aganim@lemmy.world 2 points 3 days ago

On the bright side, you've now got squeaky clean disk space to fill with new projects!

load more comments
view more: next ›