Fellow Stranger
Fellow Stranger

Reputation: 34013

In what branch should I be when doing a rebase?

I have a master branch with some commits that the branch development doesn't have.

The development branch has even more commits that master doesn't have.

I want to merge the state of development to master, i.e. override whatever changes master has that development lacks.

I have been told that I should a rebase. When I read about rebase, I understand that the syntax is the following:

git rebase master

What I don't understand though, is from what branch I should write the command (to accomplish the described scenario), in master or in development?

Upvotes: 4

Views: 971

Answers (2)

Brandon Haston
Brandon Haston

Reputation: 434

Checkout development and rebase from there as so:

git checkout development
git rebase master

The latter example, git rebase master development is a shorter version of the commands above (as described in the documentation you had linked).

This will cause your development branch changes to seem as if they started from the latest commit on master (provided you don't run into any conflicts, which you'll have to resolve during a rebase if you come across them). If all goes well you will be able to then merge development into master which will act as a simple fast-forward merge.

See http://rypress.com/tutorials/git/rebasing.html for a good explanation.

Upvotes: 1

James Zhu
James Zhu

Reputation: 140

In this specific scenario, you would write the rebase command from the development branch.

This is similar to how git merge master would merge master onto your current branch.

Upvotes: 3

Related Questions