Skip to content

Git Branch Merge Rebase Strategy

byersd edited this page Feb 13, 2014 · 2 revisions

Please see below for a suggested Git branch/merge/rebase strategy.

Create a feature branch

  • git checkout -b feature-branch
  • git push -u origin feature-branch

Do work

(may repeat several times while you're working on your feature)

  • do work, run tests
  • git add <your files>
  • git commit
  • git checkout master
  • git pull origin master
  • git checkout feature-branch
  • git rebase master
  • run tests, fix conflicts
    Make sure the tests are passing with merged changes from master
  • push branch to remote to run travis: git push origin feature branch

(may repeat several times while you're working on your feature)

Update master using a pull request

Update master without a pull request

Note: This will only work if you have been added as a collaborator.

  • git checkout master
  • git rebase feature-branch
  • git push origin master
  • git branch -d feature-branch

I'm sure this could do with further work - please feel free to comment/update.

I updated this to use rebase when updating the master branch. Here's a great explanation.