Merging Pull Requests Without Leaving Shell With Github Cli

Pavol Kutaj
2 min readOct 15, 2020

--

usecase

The concern is documenting how the github CLI’s feature for creating pull requests from the command line has modified the feature-branching workflow by introducing a way how to push the work into the repo with the simultaneous creation of a pull request.

1. work → stage → commit

  • checkout a branch
git checkout -b test
  • do the work (create a test file here)
  • add to the index && commit to the repo
git add . && git commit -m "test github cli"

2. create PR

  • do not push the branch with git
  • run
gh pr create
  • the github cli will use the proper git command to push the feature branch and create the PR as well!

3.1. list

  • lists all current pull requests
gh pr list

3.2. view

  • gives you the name + status + #of commits + body + browser URL
gh pr view

3.3. diff

  • outputs all the changes done in the pull requests
gh pr diff

4. merge PR

  • merge the PR and delete the feature branch if so intended
gh pr merge

5. git pull

  • do not forget to pull the changes again, if continuing in further work
  • this prevents merge conflicts
git pull

--

--

No responses yet