Skip to content

Instantly share code, notes, and snippets.

@jeffreyjurgajtis
Last active January 3, 2016 15:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyjurgajtis/8481982 to your computer and use it in GitHub Desktop.
Save jeffreyjurgajtis/8481982 to your computer and use it in GitHub Desktop.
Avoid merge commits
Updating your local master with origin/master

$ git checkout master
$ git fetch --all --prune
$ git rebase origin/master

Updating your feature branch with your local master

$ git checkout my-feature-branch
$ git rebase master

Squashing feature branch commits

$ git checkout my-feature-branch
$ git rebase -i HEAD~n // n being the number of commits that you'd like to combine

Pushing your completed feature branch to origin/master

$ git checkout master
$ git rebase origin/master // ensure master is up-to-date
$ git checkout my-feature-branch
$ git status // ensure feature branch is clean
$ git rebase master // sets all new master commits under your feature commits
$ git checkout master
$ git rebase my-feature-branch // combines your feature branch with master without a merge!!
$ git push origin master // auto-closes any open pull requests for your feature branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment