Write down a sequence of git commands for a “Rebase Workflow”

Technology CommunityCategory: GitWrite down a sequence of git commands for a “Rebase Workflow”
VietMX Staff asked 3 years ago

Rebasing replays changes from one line of work onto another in the order they were introduced, whereas merging takes the endpoints and merges them together.

  1. Create a feature branch
$ git checkout -b feature
  1. Make changes on the feature branch
$ echo "Bam!" >>foo.md
$ git add foo.md
$ git commit -m 'Added awesome comment'
  1. Fetch upstream repository
$ git fetch upstream
  1. Rebase changes from feature branch onto upstream/master
$ git rebase upstream/master

5.Rebase local master onto feature branch

$ git checkout master
$ git rebase feature
  1. Push local master to upstream
$ git push upstream master

Rebasing gives you a clean linear commit history and creates non-obvious benefits to your project if used diligently. Think of it as taking a line of work and pretending it always started at the very latest revision.