Show HN: Effective Git

(github.com)

37 points | by nola-a 16 days ago

4 comments

  • tomtom1337 13 days ago
    I'd recommend using git switch instead of checkout, since the checkout command is so overloaded. And restore instead of checkout for restoring changes.
    • nola-a 10 days ago
      I know it's just my opinion, but even though 'checkout' is overloaded with meanings, I always find it the most unambiguous. Some of my coworkers keep telling me to use 'switch' instead, but every time I try it, I find myself wondering how it works
      • tomtom1337 10 days ago
        I get it but I think you're essentially saying "I learnt it this way and it's hard to change once I learnt it that way". My argument is that "when teaching others, it's better to teach them to use switch and restore rather than checkout".
    • musicmatze 12 days ago
      Unfortunately, muscle memory cannot be changed that easily. And thanks to the git maintainers, the checkout command still exists, because apparently they know that.
  • ralferoo 13 days ago
    After using git for about 15 years, I still find "git merge" unpleasant and hard to track changes. I've always had better experiences rebasing my branch on top of the current main and then committing the resultant changes. Of course it helps if you are regularly rebasing from main rather than leaving it until the end, but the process still usually feels cleaner than with git merge.

    The only downside of rebasing (for me) is it looks confusing when commits aren't sequentially in date order, and sometimes it feels like you need to resolve the same conflict several times (once for each commit that gets rebased if they touch the same code) but that usually works out better for me than a regular merge.

    • nola-a 10 days ago
      If you're working on your private branch and can tolerate a small loss of accuracy in your commit history, then rebasing is fine. However, if you sometimes use reflog to recover from minor issues, it can become more difficult after you've rebased.
  • eviks 13 days ago
    > This document wants to be a reference for best practices in the daily use of Git

    Then it wouldn't stick to the most ineffective interface for git - cli

  • Valodim 13 days ago
    Eh. If you're interested in sharpening your vcs toolchain, just learn jj already
    • yogorenapan 13 days ago
      I've learnt jujutsu. It took me a couple weeks to get it but 100℅ worth it. I've always intuitively understood git but jj does make a lot of annoying things easy. My commit history is now much cleaner than ever before. It's not for everyone though. Takes a lot of upfront investment to learn when git is often already good enough.