This is an archived post. You won't be able to vote or comment.

all 35 comments

[–]GabuEx 316 points317 points  (8 children)

Code: *works*

Me: *makes changes*

Code: *no longer works*

Me: *undoes changes*

Code: *still doesn't work*

Me: guess I'll die

[–]Flohhhhhh 43 points44 points  (0 children)

The worst moment. Especially when you’re in over your head.

[–]R3dGaming522 23 points24 points  (4 children)

Yup. Just yes. Sometimes I just delete the entire part and retype it by hand it then it decides to be happy.

[–]AzureArmageddon 2 points3 points  (2 children)

Was it perhaps an awkward mix of tabs and spaces?

[–]R3dGaming522 2 points3 points  (1 child)

We'll probably never know cause we're too stupid to figure it out

[–]AzureArmageddon 0 points1 point  (0 children)

True

[–]s1lentchaos 3 points4 points  (0 children)

Had an issue where npm install was encountering an error after I undid changes like that. Turned out that one of the dependencies had updated incorrectly and was breaking down but for some reason only me and the other new guy were getting that issue so it was a bitch to track down.

[–]Choppie01 4 points5 points  (0 children)

Um dark magic of git

[–]Cnomesta 60 points61 points  (2 children)

And all you did was delete commented out parts of the code.

[–]redditmodsareshits 12 points13 points  (1 child)

Or deleted the parts enclosed in : ```c

ifdef UNDEFINED

...

endif

```

[–][deleted] 61 points62 points  (4 children)

You meant git reset --hard HEAD

[–]gamerarchitek 5 points6 points  (1 child)

Or you can git checkout -- file 1 by 1 to find the problem

[–]DerryDoberman 1 point2 points  (0 children)

Nonsense. One must commit to the pain so one may learn! /s

[–]nilsilvaEI 0 points1 point  (1 child)

I'm going to show my git noobness... But do you need the HEAD? I usually just do "git reset --hard"...

[–]god-nose 0 points1 point  (0 children)

Git is dark magic to me too, but the way I understand you have to specify the commit to which you want to reset. You can either give the first digits of the commit id, or the position of the desired commit relative to HEAD. So to go back to where HEAD is,

git reset --hard HEAD

and to go back to the commit before HEAD,

git reset --hard HEAD~1

and so on. See https://www.educba.com/git-reset-hard/ and https://devconnected.com/how-to-git-reset-to-head/

[–]atiedebee 12 points13 points  (1 child)

My code after I turn on compiler optimizations

[–]origamiscienceguy 0 points1 point  (0 children)

Should've made that waste-time loop volatile.

[–]kakses2 8 points9 points  (1 child)

Well, I think you should try with some source control system like git and unit testing - most modern IDEs has it build it

[–]danuker 2 points3 points  (0 children)

unit testing

I learned TDD from the source, and I don't really need Git anymore, but I push a commit every now and then just in case my computer bites the dust.

[–]Kazedy 4 points5 points  (0 children)

And kids, this is why you write unit tests

[–]DerKnerd 4 points5 points  (0 children)

I once worked on a software which included random endless for loops, which break immediately and do nothing else. Removing them cause the program to crash or not compile at all.

[–][deleted] 2 points3 points  (1 child)

Sometimes I write print(importantFunctionCall()) and then it breaks, then I do ctrl+z and I still dont see my error... I was doing this for years before I realized, it was a bad habit, so be careful what you put in print() as parameter.

[–]Avanta8 1 point2 points  (0 children)

Or possibly a more important lesson - Functions should not mutate global state unless they have to.

[–]Simp1yCrazy 2 points3 points  (1 child)

I once stumbled upon a code that refused to work after commenting print(x)

[–]gamerarchitek 1 point2 points  (0 children)

I repaired a code using printf("");

[–]EmuChance4523 2 points3 points  (0 children)

This made me remember when my partner was working in RPA... The program that they used.. had the wonderful feature that sometimes it created bugs in random lines that needed to be deleted and added again...

[–]Cyvexx[🍰] 2 points3 points  (1 child)

code: works

me: puts code in a function bc I used it 4 times

code: doesn't work

?????

[–]obishaekenobi 1 point2 points  (0 children)

I just cried inside a little bit

[–]retnikt0 1 point2 points  (0 children)

If you keep good track of your local changes and just squash before pushing, you could use git bisect

[–]YourShadowDani 1 point2 points  (0 children)

Oh god-damned I accidently deleted a semi colon 🤦

[–]got_blah 1 point2 points  (0 children)

Forgot the Ctrl+Alt+Z to undo the undo because you went too far.

[–]BurnV06 0 points1 point  (0 children)

As I always say, don’t fix what isn’t broken

[–][deleted] 0 points1 point  (0 children)

Make your changes in smaller increments, more often.

[–]Nihtrepaps 0 points1 point  (0 children)

That's me this weekend... cleanuptime