1

I want to rebase my feature branch into dev branch, so I do

git checkout feature git rebase dev 

then I get

Current branch feature is up to date 

thats already strange, shouldn't it update the dev and not the feature?

further

git checkout dev git log 

shows that there is no new commits from the feature added. What am I doing wrong?

and

2
  • git rebase changes the current branch, no the branch you want to rebase on. Commented Oct 27, 2016 at 22:16
  • I guess probably what you want to do is git checkout feature, git rebase dev, git checkout dev, and git merge feature. This first updates feature's start point to the tip of dev, and then merges the commits made in feature into dev. Commented Oct 27, 2016 at 22:43

1 Answer 1

1

I'm assuming dev is your primary branch.

If you initial branched feature off of dev (or another branch that was at the same commit point as dev HEAD) and no changes have been commited to dev since that branching, when inside feature (as you are by doing the checkout) if you rebase to dev, nothing should happen. HEADcommit of dev is already feature's base commit.

If commits had been made to dev, then the rebase would have rebased feature to the new dev HEAD.

You don't want to rebase dev, you rebase your feature branch if needed (if dev having changed while working on your feature), then merge the rebased feature branch back into dev.

Here's my flow assuming dev is my primary branch:

git checkout dev git checkout -b feature 

Now I'm in my feature branch. I Made some changes to feature branch commit them, maybe dev has changed in meantime. Still on feature branch, so changing back to dev to look for any changes

git checkout dev git pull origin dev 

So changes happened on dev, so I want to rebase my feature branch

git checkout feature git rebase dev 

Now I'm ready to merge my feature branch back into dev

git checkout dev git merge --squash feature 

Squash is optional, but it condenses changes in the feature branch into a single commit on merging back to dev.

Finally, push the new dev back up for others to enjoy

git push origin dev 
Sign up to request clarification or add additional context in comments.

1 Comment

thanks, correct I didnt have changes in the dev branch, so simple merge helped out

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.