docs/How-To-Open-a-Homebrew-Pull-Request.md
The following commands are used by Homebrew contributors to set up a fork of Homebrew's Git repository on GitHub, create a new branch and create a GitHub pull request ("PR") for the changes in that branch.
The type of change you want to make influences which of Homebrew's main repositories you'll need to send your pull request to. If you want to submit a change to Homebrew's core code (the brew implementation), you should open a pull request on Homebrew/brew. If you want to submit a change for a formula, you should open a pull request on the homebrew/core tap, while for casks you should open the pull request on the homebrew/cask tap or another official tap, depending on the formula type.
brew bump-formula-pr to do everything (i.e. forking, committing, pushing) with a single command. Run brew bump-formula-pr --help to learn more.brew bump-cask-pr to do everything (i.e. forking, committing, pushing) with a single command. Run brew bump-cask-pr --help to learn more.brew code pull requestFork the Homebrew/brew repository on GitHub.
Change to the directory containing your Homebrew installation:
cd "$(brew --repository)"
Add your pushable forked repository as a new remote:
git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/brew.git
<YOUR_USERNAME> is your GitHub username, not your local machine username.Before creating a new formula, please read Acceptable Formulae.
Fork the Homebrew/homebrew-core repository on GitHub.
Tap (download a local clone of) the repository of core Homebrew formulae:
brew tap --force homebrew/core
Change to the directory containing Homebrew formulae:
cd "$(brew --repository homebrew/core)"
Add your pushable forked repository as a new remote:
git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/homebrew-core.git
<YOUR_USERNAME> is your GitHub username, not your local machine username.Before creating a new cask, please read Acceptable Casks.
Fork the Homebrew/homebrew-cask repository on GitHub.
Tap (download a local clone of) the repository of core Homebrew casks:
brew tap --force homebrew/cask
Change to the directory containing Homebrew casks:
cd "$(brew --repository homebrew/cask)"
Add your pushable forked repository as a new remote:
git remote add <YOUR_USERNAME> https://github.com/<YOUR_USERNAME>/homebrew-cask.git
<YOUR_USERNAME> is your GitHub username, not your local machine username.To make changes on a new branch and submit it for review, create a GitHub pull request with the following steps:
Check out the main branch:
git checkout main
Retrieve new changes to the main branch:
brew update
Create a new branch from the latest default branch:
git checkout -b <YOUR_BRANCH_NAME> origin/HEAD
Make your changes. For formulae or casks, use brew edit or your favourite text editor, using the guidelines in the Formula Cookbook or Cask Cookbook for reference.
bottle do block in the formula, don't remove or change it; we'll update it when we merge your PR.Test your changes by running the following, and ensure they all pass without issue. brew lgtm --online runs the relevant online brew audit checks for changed and new formulae and casks, and runs brew test for formulae when the latest version is installed.
For formulae:
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <FORMULA>
brew lgtm --online
For casks:
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --cask <CASK>
brew uninstall --cask <CASK>
brew lgtm --online
Make a separate commit for each changed formula with git add and git commit. Each formula's commits must be squashed.
<FORMULA_NAME> <NEW_VERSION>", e.g. "source-highlight 3.1.8".Upload your branch of new commits to your fork:
git push --set-upstream <YOUR_USERNAME> <YOUR_BRANCH_NAME>
Go to the relevant repository (e.g. https://github.com/Homebrew/brew, https://github.com/Homebrew/homebrew-core, etc.) and create a pull request to request review and merging of the commits from your pushed branch. Explain why the change is needed and, if fixing a bug, how to reproduce the bug. Make sure you have done each step in the checklist that appears in your new PR.
Await feedback or a merge from Homebrew's maintainers. We typically respond to all PRs within a couple days, but it may take up to a week, depending on the maintainers' workload.
Thank you!
We allow you to create issues and pull requests with AI/LLM with the following requirements:
To respond well to feedback:
needs response label on a PR means that the Homebrew maintainers need you to respond to previous comments.To make changes based on feedback:
Check out your branch again:
git checkout <YOUR_BRANCH_NAME>
Make any requested changes and commit them with git add and git commit.
Squash new commits into one commit per formula:
git rebase --interactive origin/HEAD
If you are working on a PR for a single formula, git commit --amend is a convenient way of keeping your commits squashed as you go.
Push to your remote fork's branch and the pull request:
git push --force
Once all feedback has been addressed and if it's a change we want to include (we include most changes), then we'll add your changes to Homebrew. Note that the PR status may show up as "Closed" instead of "Merged" because of the way we merge contributions. Don't worry: you will still get author credit in the actual merged commit.
Well done, you are now a Homebrew contributor!