As aliases

alias g-log="git log --graph --format='format:%C(yellow)%h%C(reset) %s %C(magenta)%cr%C(reset)%C(auto)%d%C(reset)'"
alias g-history='gitk --all &'
alias g-checkout='git checkout $(git branch --sort=-committerdate --no-merged | fzf)'
alias g-commit='git citool &'
alias g-amend='git citool --amend &'
alias g-rebase='git rebase --interactive --autosquash'
alias g-pull='git pull --verbose --rebase'
alias g-pushf='git push --verbose --force-with-lease'
alias g-status='git status --ignored'
alias g-clean='git clean -fdx && git reset --hard && git submodule foreach --recursive git clean -fdx && git submodule foreach --recursive git reset --hard'
    • lysdexic@programming.dev
      link
      fedilink
      English
      arrow-up
      14
      arrow-down
      4
      ·
      edit-2
      8 months ago

      If you need anything more complex than cherrypick, you already screwed up big time.

      I think this is a clueless comment. You can use Git to greatly improve your development workflow if you dare going beyond the naive pull/commit/push workflow.

      Take for example interactive rebase. It let’s you do very powerful stuff such as changing the order of commits in a local branch and merge/squash contiguous commits. This unlocks workflows such as peeling off bugfix and cleanup commits from your local feature branch without having to switch branches. I’m talking about doing something like:

      a) - you’re working on your task, b) - you notice a bug that needs fixing, c) - you fix the bug and commit your fix, e) - you continue to work on your task, f) - you notice a typo in your bugfix code, so you post a fixup commit. g) - you post a few commits to finish your task, h) - you noticed your bugfix commit didn’t had the right formatting, so you post a couple of commits to lint your code both in your bugfix commits and task.

      When you feel you’re done, you use interactive rebase to put everything together.

      a) you reorder your commits to move your bugfix commit to the top of your local branch, followed by the typo fixup commit and the linter commit. b) you mark both the typo and linter commits as fixup commits to merge them with the bugfix one, c) you post a PR with the single bugfix commit, d) you finally post a PR for your task.

      Notice that thanks go git interactive rebase you did not had to break out of your workflow or do any sort of context switch to push multiple PRs. You just worked on things you had to work, and in the end you just reorganize the commit history in your local branch to push your work.

      Is this what you call “screwed up big time”?

      • AggressivelyPassive@feddit.de
        link
        fedilink
        arrow-up
        11
        arrow-down
        4
        ·
        8 months ago

        That sounds like a solution in desperate need for a problem.

        All the “problems” you described boil down to “switching branches is evil”.

        • lysdexic@programming.dev
          link
          fedilink
          English
          arrow-up
          4
          arrow-down
          16
          ·
          8 months ago

          That sounds like a solution in desperate need for a problem.

          It’s ok if you never did any professional software development work. Those who do have to go through these workflows on a daily basis. Some people don’t even understand why version control systems are used or useful, and that is perfectly ok. Those who do work have to understand how to use their tools, and those who don’t can go about their life without even bothering with this stuff.

          • AggressivelyPassive@feddit.de
            link
            fedilink
            arrow-up
            10
            arrow-down
            1
            ·
            8 months ago

            And those who don’t immediately insult everyone at the slightest opposition are the ones who get things done.

            Seriously, your line of thinking is exactly the one of those weird colleagues nobody wants to work with, because they insist on their idiosyncratic bullshit.

            The “problem” you described above is - if it exists at all - extremely niche, and hardly anything anyone should solve with git, but with processes.

            Maybe you have a use for it in your workflow - but that might also mean your workflow might not be the best.

            • lysdexic@programming.dev
              link
              fedilink
              English
              arrow-up
              3
              arrow-down
              6
              ·
              8 months ago

              And those who don’t immediately insult

              Pointing out someone’s claim that they don’t care about processes when it’s the critical aspect of any professional work is hardly what I’d call an insult.

              Just go ahead and say you don’t use a tool and thus you don’t feel the need to learn it. Claiming that a tool’s basic functionality is “a solution in search for a problem” is as good as announcing your obliviousness,and that you’re discussing stuff you hardly know anything about.

              • AggressivelyPassive@feddit.de
                link
                fedilink
                arrow-up
                4
                arrow-down
                1
                ·
                8 months ago

                So, once again we are at a point in subs like this were the question is: Oblivious autist or arrogance bordering on being an asshole?

                Pointing out someone’s claim that they don’t care about processes when it’s the critical aspect of any professional work is hardly what I’d call an insult.

                See, you’re not claiming that processes are important, you’re claiming that your process is important and your interpretation of Git is the only one allowed, and that everyone who disagress with your opinion is an idiot.

                That is factually wrong, extremely close-minded, unproductive, and really really arrogant

                • lysdexic@programming.dev
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  arrow-down
                  3
                  ·
                  edit-2
                  8 months ago

                  See, you’re not claiming that processes are important, you’re claiming that your process is important and

                  No, I’m claiming that processes are important.

                  It’s important that stumbling upon a tangentially related bug or even linting issue does not block your work, forces you to fork your work, nor forces you to work around it. It’s important that you can just post a small commit, continue with your work, and only handle that in the very end.

                  It’s also important that you can work on your feature branch as you please, iterate on tests and fixes as you see fit, and leave cleanup commits to the very end so that your PR contributes a clean commit history instead of reflecting your iterations.

                  It’s important that you can do any work you feel is important without having to constrain yourself to adapt your work to what you absolutely have to push your changes in a squraky clean state without iterations.

                  It’s important that you can work on tasks as well as cleanup commits, and not be forced to push them all in a single PR because you are incapable of editing your local commit history.

                  It’s not about my workflow. It’s about the happy path of a very mundane experience as a professional software developer, specially in a team which relies on a repository’s commit history to audit changes and pinpoint regressions.

                  This is stuff anyone who works in professional teams can tell you right away. Yet, you talk about this if it was a completely alien concept to you. Why is that? Is everyone around you wrong and your limited superficial experience dictates the norm?

                  Yet you talk about autism.

                  • Modern_medicine_isnt@lemmy.world
                    link
                    fedilink
                    arrow-up
                    1
                    ·
                    8 months ago

                    I work in professional teams, have been for decades. Noticing an unrelated bug doesn’t block my workflow. I can fix it as part of the same pr, or just stash my changes and make a new branch for it. You sound like the people who demand everyone alphabetize thier import statements because they don’t want to use the ide’s search.
                    It’s okay to have your own way and preferences, but they are yours, not everyone elses.

        • lysdexic@programming.dev
          link
          fedilink
          English
          arrow-up
          4
          arrow-down
          3
          ·
          8 months ago

          It’s ok if you don’t feel a need to change your persona workflow.

          Nevertheless I’m not sure you understood the example, so I’m not sure you fully grasp the differences.

          The whole point of my example was to point out the fact that, thanks to interactive rebase, you do not even need to switch branches to work on multiple unrelated PRs. You can just keep going by doing small commits to your local feature branch and keep doing what you’re doing. In the end all you need to do is simply reorder, squash, and even drop commits to put together multiple PRs from commits that are built upon each other.

          Simple, and straight to the point.

          • porous_grey_matter@lemmy.ml
            link
            fedilink
            arrow-up
            5
            arrow-down
            3
            ·
            8 months ago

            I think I understood the example; I think it’s faster to switch branches for the bug-fix than to reorder those commits later

            • lysdexic@programming.dev
              link
              fedilink
              English
              arrow-up
              3
              arrow-down
              6
              ·
              8 months ago

              See, I don’t think you understood the example. The commits built upon each other (bugs are fixed while you work on the task, and to work on your task you need the bugs to be fixed) and reordering commits not only take no time at al but they are also the very last thing you do and you have to do the just once.

              • porous_grey_matter@lemmy.ml
                link
                fedilink
                arrow-up
                7
                arrow-down
                1
                ·
                edit-2
                8 months ago

                Oh, okay. I’ve never encountered a situation where I needed that bug fixed for the task but it shouldn’t be fixed as part of the task; if they’re touching the same functionality like that I really don’t see the need for two PRs. But sure, sounds helpful in that really niche case.

                • lysdexic@programming.dev
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  arrow-down
                  5
                  ·
                  edit-2
                  8 months ago

                  Oh, okay. I’ve never encountered a situation where I needed that bug fixed for the task but it shouldn’t be fixed as part of the task;

                  So you never stumbled upon bugs while doing work. That’s ok, but others do. Those who stumble upon bugs see the value of being able to sort out local commits with little to no effort.

                  Also, some teams do care about building their work on atomic commits, because they understand the problems caused by mixing up unrelated work on the same PR, specially when auditing changes to track where a regression was introduced. You might feel it’s ok to post a PR that does multiple things like bumping up a package version, linting unrelated code, fixing an issue, and post comments on an unrelated package, but others know those are four separate PRs and should be pushed as four separate PRs.

                  if they’re touching the same functionality like that I really don’t see the need for two PRs.

                  That’s ok, not everyone works with QA teams. Once you grow over a scale where you have people whose job is to ensure a bug is fixed following specific end to end tests and detect where a regression was introduced, you’ll understand the value of having tests that verify if a bug is fixed, and only afterwards proceed with changing the user-facing behavior. For those with free-for-all commits where “fixes bug” and “update” show up multiple times in their commit history, paying attention to how a commit history is put together is hardly a concern.

                  • porous_grey_matter@lemmy.ml
                    link
                    fedilink
                    arrow-up
                    3
                    ·
                    edit-2
                    8 months ago

                    So you never stumbled upon bugs while doing work

                    That’s not what I said… Either the bug is related to the task, or it isn’t. If it’s not related to the task, there’s no reason to fix it on the same local branch either.

                    Also, some teams do care about building their work on atomic commits, because they understand the problems caused by mixing up unrelated work on the same PR, specially when auditing changes to track where a regression was introduced. You might feel it’s ok to post a PR that does multiple things like bumping up a package version, linting unrelated code, fixing an issue, and post comments on an unrelated package, but others know those are four separate PRs and should be pushed as four separate PRs.

                    Well, these things don’t meet the standards of your earlier example at all. Linting unrelated code and posting comments on an unrelated package clearly aren’t needed for someone to work on the main issue fix they’re doing. If it’s unrelated code you again lose nothing by switching branches to do the work.

      • Modern_medicine_isnt@lemmy.world
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        8 months ago

        Yes, why are you wasting time with all that. No one uses the commit history to the level that any of that matters. If it does, you ci flow is the problem.

    • GissaMittJobb@lemmy.ml
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      8 months ago

      I disagree wholeheartedly with this. I consider the commit history as documentation for pull requests and for future history, and as such I make liberal use of interactive rebasing to curate my commits.

      Rebasing in general is one of those things that I picked up fairly late, but now it’s essential to my git workflow.

      • TechNom (nobody)@programming.dev
        link
        fedilink
        English
        arrow-up
        3
        ·
        8 months ago

        What’s ironic is that rebases aren’t as hard as many consider it to be. Once you’ve done it a couple of times, you just do it everyday as easily as you commit changes.

        • GissaMittJobb@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          8 months ago

          Absolutely. I think it helps a lot to understand the mechanics of git and rebasing, but after a few times it just makes more sense than merging, really.

    • fidodo@lemmy.world
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      2
      ·
      edit-2
      8 months ago

      If you’re doing more complex stuff all the time then yes that’s an indication of a problem, but despite your best efforts, complex situations or screw ups do happen and it’s good to know how to fix them, especially if you’re a senior dev that needs to help the rest of the team and resolve conflicts between feature branches. The whole team can’t be perfect all the time.

      Also most of the tips in the article aren’t even about branch management and more about optimizations for huge projects or introspection into the history of large projects.