user2924482
user2924482

Reputation: 9120

GIT: Rease local master with local branch

I have local branch (development) but I want merge my changes to master.

I tried the following:

form my development branch:

git rebase origin/master

But what happened my development branch lost my changes and I had to reset my development branch.

How can I rebase my master branch with development branch?

Upvotes: 0

Views: 55

Answers (1)

larsks
larsks

Reputation: 311288

If you are on your development branch (let's say it's called dev):

git checkout dev

And you rebase it on the remote master branch:

git rebase origin/master

This should result your changes on top of the latest change in origin/master. Note that depending on your local activity, master may not have the same content as origin/master so make sure you are rebasing on top of the correct branch.

This shouldn't cause any changes to be lost, although depending on the changes involved it can result in conflicts that need to be resolved manually.

If you aren't sure you're doing the right thing, remember that you can always test things out on a new branch. E.g., to checkout a new branch named testbranch that is identical to your dev branch:

git checkout -b testbranch dev

Now you can play with rebase without making any changes to your dev branch.

Upvotes: 2

Related Questions