About Merging Pull Requests with GitHub CLI

This is my workflow for merging branches with GitHub CLI:

1. Use the main branch.

2. Select a pull request's branch to checkout

$ gh pr list
$ gh pr checkout

3. Test and fix the code if necessary

$ git add .
$ git commit -m "Fixed bugs"
$ git push

4. Merge the pull request back to the main branch.

$ gh pr merge

GitHub CLI asks you interactively which PR id to choose in the checkout and merge commands. Alternatively, you can pass those ids as command-line parameters.

Tips and Tricks Development Git GitHub CLI