+

Search Tips   |   Advanced Search

Rebasing a pull request

You may find that your pull request (PR) is out-of-date and needs to be rebased. This can happen for several reasons:

Rebasing the branch used to create your PR will resolve both of these issues.


Configuring your remotes

Before you can rebase your PR, you need to make sure you have the proper remotes configured. These instructions apply to any repository on GitHub, including collections repositories. On other platforms (bitbucket, gitlab), the same principles and commands apply but the syntax may be different. We use the ansible/ansible repository here as an example. In other repositories, the branch names may be different. Assuming you cloned your fork in the usual fashion, the origin remote will point to your fork:

However, you also need to add a remote which points to the upstream repository:

Which should leave you with the following remotes:

Checking the status of your branch should show your fork is up-to-date with the origin remote:


Rebasing your branch

Once you have an upstream remote configured, you can rebase the branch for your PR:

This will replay the changes in your branch on top of the changes made in the upstream devel branch. If there are merge conflicts, you will be prompted to resolve those before you can continue.

After you rebase, the status of your branch changes:

Don't worry, this is normal after a rebase. You should ignore the git status instructions to use git pull. We'll cover what to do next in the following section.


Updating your pull request

Now that you've rebased your branch, you need to push your changes to GitHub to update your PR.

Since rebasing re-writes git history, you will need to use a force push:

Your PR on GitHub has now been updated. This will automatically trigger testing of your changes. You should check in on the status of your PR after tests have completed to see if further changes are required.


Getting help rebasing

For help with rebasing your PR, or other development related questions, join us on our #ansible-devel IRC chat channel on freenode.net.


See also

The Ansible Development Cycle

Information on roadmaps, opening PRs, Ansibullbot, and more

Next Previous