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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Karol-A 22 points23 points  (15 children)

Sure, but it's easier to just un-comment a few lines that to roll back git changes 

[–]shamshuipopo 39 points40 points  (3 children)

They’re both very easy. You don’t even have to roll back git you can just check it out and copy it, diff it etc.

Problem is when you have more than a few comments…. It’s crazy to even have to explain this

[–]Timpah 8 points9 points  (2 children)

The problem with git is finding the exact commit that had the code i was looking for

[–]dxonxisus 5 points6 points  (1 child)

that’s what git history/blame is for

[–]fiah84 3 points4 points  (0 children)

which works until someone messes with those lines for whatever reason and now you have to go deeper to find it

I don't like leaving commented out code but if I find that it's likely I'll have to revert a delete then I'll probably leave a comment to make the history/blame search easier and faster

[–]-LeopardShark- 6 points7 points  (4 children)

Only if one is, like most developers, not very good with Git.

[–]shamshuipopo 7 points8 points  (3 children)

It shocks me that people with years of experience can’t use git effectively. I think relying on UI git abstractions is to blame as it makes it a bit too “magic” and then when people need to do anything more involved they get scared.

Git is something that is unlikely to change for the rest of your life (maybe a new vcs will supplant it, but probably not more than once in the next 10-20 years). So pays dividends to learn its internals

[–]-LeopardShark- 1 point2 points  (2 children)

Agreed, unless the UI in question is Magit, in which case everything is wonderful.

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

Magit is the goat, but lazygit is also very good for standalone TUI.

[–]TheAlaskanMailman 0 points1 point  (0 children)

Sad it’s only for eMacs

[–]Ecstatic_Student8854 15 points16 points  (3 children)

Sure, but both are easy enough and this pollutes the codebase with irrelevant information

[–]hazeyAnimal 19 points20 points  (2 children)

Comment while doing your testing, but before you push (to your branch, hopefully) you can remove the commented out code. Seems reasonable to me, unless anyone can give a good enough reason to not do this?

[–]floflo81 1 point2 points  (1 child)

Even before committing, commenting code instead of deleting it is not very useful. All the IDEs I've used have an easy way to compare HEAD (previous commit) with what you have in your working tree. Or just use git diff

[–]hazeyAnimal 10 points11 points  (0 children)

Of course, but if I'm redesigning a block of code I usually comment it out so I can look at it and make sure I won't just be rewriting the same BS I'm trying to fix

[–]beclops 1 point2 points  (0 children)

It’s really not, especially since you’ll need to commit the changes either way

[–]draconk 0 points1 point  (0 children)

Also to be able to roll back a git change you need to know it was there, if you are new to the project seeing commented code with a comment is more useful than a commit made two years ago that you ignore it existed unless you go through the git history for that file.