Skip to content

Instantly share code, notes, and snippets.

@leocencetti
Last active April 8, 2024 15:11
Show Gist options
  • Save leocencetti/bf6e3d215070af7e1cd2579da674a388 to your computer and use it in GitHub Desktop.
Save leocencetti/bf6e3d215070af7e1cd2579da674a388 to your computer and use it in GitHub Desktop.
git-amendabot
#!/usr/bin/env bash
set -e
ROOT=$(pwd)
BRANCH=$(gh pr view --json headRefName --jq .headRefName $1)
WORKTREE=worktrees/${BRANCH//\//-}
git fetch origin ${BRANCH}
git worktree add ${WORKTREE} ${BRANCH}
cd ${WORKTREE}
git commit -q --amend --no-edit
git push -q -f
cd ${ROOT}
git worktree remove -f ${WORKTREE}
git branch -D ${BRANCH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment