DEV Community

Discussion on: Rebase to the future!

Collapse
 
dkarlovi profile image
Dalibor Karlović

Bob can actually do this to fix it:

  1. git checkout -b feature-bob - creates a new branch from the existing feature branch for Bob, with his changes
  2. git checkout feature - go back to the original branch
  3. git fetch origin - fetch changes from remote after the rebase
  4. git reset --hard origin/feature - resets Bob's current feature branch to be identical with remote's
  5. git checkout feature-bob - go back to Bob's branch
  6. git rebase feature - include your changes into his branch

Bob now keeps working on his feature branch and just rebases on top of yours. That way you can work on the same feature, but still do your own rebase.

Collapse
 
konrad_126 profile image
konrad_126 • Edited

Hello Dalibor,

This solution would fit the "no nice way for him to fix this situation" category in my opinion :)

Collapse
 
jsgarmon profile image
JSG

From the Bob's local feature branch, he can accomplish all this with just:

  1. git pull --rebase origin feature

I use pull --rebase all the time when I don't want a merge commit every time I pull down from the public branch. Simply replays my local commits on top of the remote head.

Collapse
 
jessekphillips profile image
Jesse Phillips

Yeah I was going to mention this in the fetch flow.

It actually makes collaborating with rebase completely acceptable as long as you never merge which I think may work at times too.