1

I'm new to git commands and first time need to do such a thing and have no idea where to start What i have now:

branch-name          E
                    /
master A - B - C - D - F- G

What I want to have

branch-name                 E
                           /
master A - B - C - D - F- G

How can i accomplish that?

Edit: Error message

git rebase master ended up with error mesage:

CONFLICT (modify/delete): file.txt deleted in HEAD and modifie d in Initial commit. Version Initial commit of file.txt left in tree. Failed to merge in the changes. Patch failed at 0001 Initial commit The copy of the patch that failed is found in: project-path/.git/rebase-apply/patch Warning: Your console font probably doesn't support Unicode. If you experience s trange characters in the output, consider switching to a TrueType font such as L ucida Console!

Harry89pl
  • 2,415
  • 12
  • 42
  • 63

1 Answers1

2

It is a simple git rebase:

git checkout branch-name
git rebase master

But you might have to force the push of branch-name after the rebase (if you already pushed it before): git push --force.
That could be problematic if others were already working on that same branch in their own local repo, as they would have to reset it to that new history.
In that case (branch already pushed), alternatives would be (similar to what is discussed in "alternative to rebasing pushed commits"):

  • merge master to branch-name (not always considered as a best practice)
  • a git cherry-pick in a new branch
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `git rebase --onto master branch-name branch-name` could also work – Joseph K. Strauss Jan 05 '15 at 22:42
  • I think it's what i needed but got some conflict with rebase (deleted file in both branch-name and master) – Harry89pl Jan 05 '15 at 22:54
  • @harry180 I have to go for a few hours, but leave the exact error message. – VonC Jan 05 '15 at 22:58
  • @harry180 so it seems similar to http://stackoverflow.com/q/5516391/6309: `git add -A .` and `git rebase --continue` should allow you to resume the rebase. – VonC Jan 05 '15 at 23:16
  • yep u r right that helped :) Thanks a lot :) what -A stands for? – Harry89pl Jan 05 '15 at 23:20
  • @harry180 it adds new/updated files as well as deleted files: http://stackoverflow.com/a/16162511/6309 and http://stackoverflow.com/a/2190440/6309 – VonC Jan 05 '15 at 23:23