11
JS96
5y

I just found out you can commit single lines of a file without the necessity to remove temporarily debug lines every time ... it has blown my mind.

Comments
  • 8
    so that's what the "stage hunk" does in sublime merge. I always thought It was a term for when I am singing karaoke
  • 2
    Yeah, that's possible with git commit -p.

    But then you commit an untested state, so you have to test that commit afterwards anyway.

    It makes some things a bit more comfortable, but you'd better get rid of those debug stuff early or incorporate it somehow permanently without affecting your release build.
  • 2
    How about using a logging framework or a simple debug flag in your code to control if you need the debug output or not?
  • 0
    @ElCapitan because you often need to debug some bit of the code only once and committing it and also including another framework will just bloat your code. Although I am aware writing shitty dependency hell code is the "in" thing to do in 2020.
  • 1
    @Mr-Myrk well of course it always depends on many factors. If you're working on a quick and dirty script for yourself or the logging framework would be bigger than the actual software it's probably better to just do it as described here or maybe even just to remove the code after testing but when I would be working on a medium to large sized project with other collaborators I probably would just pay the price to have one dependency more if this means I don't have to constantly remove and add debugging code again.
  • 0
    One of my biggest gripes with the VS integrated GIT client is it doesn't support single line commits.
  • 2
    @kwilliams
    CLI is always there for you 👍
  • 0
    git add --patch 💙
Add Comment