Skip to content

Instantly share code, notes, and snippets.

@dotherightthing
Last active February 13, 2020 20:48
Show Gist options
  • Save dotherightthing/40f4bc27bfe25fe7765303075ffa6050 to your computer and use it in GitHub Desktop.
Save dotherightthing/40f4bc27bfe25fe7765303075ffa6050 to your computer and use it in GitHub Desktop.
[Sourcetree: Rebasing a branch] #git #pr #pullrequest #merge

Sourcetree: Rebasing a branch

Submitting a Pull Request

After developing a feature in a branch, the next step is to submit a Pull Request (PR), to merge your changes into the master branch.

After submitting a PR, the PR page may show [C] on one or more files, indicating conflicts between your feature branch and the current version of the master branch.

Rebasing your branch's changes on top of the latest version of the master branch helps ensure that your code won't destabilise the code in the master branch, when it is merged into it.

Your feature branch branched off of master at a certain point, called the "base".

Rebasing points this "base" to a new place, often moving it forward to the new head of another branch.

if you have differences that aren't on the origin branch, briefly put those aside,

pull in the origin branch into your local branch,

and then apply those changes that weren't on the origin branch.

What this does is always apply your own changes on top of the (structure of) the origin branch, while leaving that stucture wholly intact.

Process

  1. Checkout a branch by double clicking on it. The branch name will be highlighted in bold.
  2. Right click on the master branch and select Rebase changes onto master
  3. The bolding will be removed from the branch name, indicating that you are on a temporary branch.
  4. If there are any conflicts, the first conflict will be shown. Resolve the conflict.
  5. To proceed to the next conflict, select Actions > Continue Rebase
  6. Proceed until all conflicts are resolved
  7. Force push the branch to master (Sourcetree > Preferences > Advanced > Allow Force Push)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment