I kept finding myself running the same repetitive Git commands each time I merged a pull request: switching to main, pulling changes, and deleting the branch. It got tedious, so I decided to automate it.
I wrote a small shell script that handles it all for me: https://gist.github.com/domhhv/be466e084704c43db132c906eaabb06d
I wrote a small shell script that handles it all for me: https://gist.github.com/domhhv/be466e084704c43db132c906eaabb06d
Comments
- Switches to `main` by default (or any branch you prefer).
- Pulls the latest changes with rebase.
- Deletes the old branch.
- Optionally stashes and pops local changes if needed (just add --stash).
Hopefully, it helps your productivity as well if you've faced the same problem!