Keeping your branch up to date
Bring the latest changes from the dev branch of Home Assistant Core into your branch, and resolve conflicts.
The dev branch moves fast. If your work takes a while, or your pull request waits for review, bring in the latest changes now and then. It avoids conflicts, and failures that only show up once your change meets the latest code.
Use git merge, not git rebase, once your pull request is open. A rebase rewrites the commits reviewers have already seen.
Make sure you have the Home Assistant repository as a remote called upstream. If you followed the environment setup, you do. Otherwise, add it:
git remote add upstream https://github.com/home-assistant/core.gitThen, from your branch:
git fetch upstream dev
git merge upstream/devIf Git reports conflicts:
- Run
git statusto see which files conflict. - Edit each file, and resolve the parts between the
<<<<<<<and>>>>>>>markers. - Add the resolved files with
git add. - Finish the merge with
git commit. The default message is fine.
Run the tests again: a merge without conflicts can still break your code.
git pushIf Git answers that the upstream branch does not match the name of your branch, your branch still follows upstream/dev. Push once with git push -u origin HEAD, and a plain git push and git pull use your fork from then on.
If the push is rejected, someone pushed to your branch in the meantime. That can be you from another computer, or a reviewer who applied a suggestion. Pull those changes in, and push again:
git pull --no-rebase
git pushIf your pull request suddenly shows commits from other people, the merge went wrong. A pull request with unrelated commits cannot be reviewed. The easiest fix is a fresh branch from the latest dev, with only your changes, and a new pull request.