• Ekky
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    9 months ago

    like this?

    # Let Git take a rest with some yummy awk chocolate logs with delicious nuts and seeds, and don't be pushy!
    git reset --hard $(git log --reverse | sed -n 1p | awk -F "[ ]" '{print $2}') && git push -f
    

    EDIT: Don’t actually run it.

    • subtext@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      9 months ago

      Can you explain what this does? I’m thinking something along the lines of reverting all commits except the very first one?

      • Ekky
        link
        fedilink
        arrow-up
        3
        ·
        9 months ago

        You are correct! It sets HEAD to the first commit and then force pushes, deleting everything after HEAD.

        Though, it only affects the currently selected branch.