1

I was working with a repo where both origin/master and master were in the same commit. I created several branches one on top of the other. Something like

master--> branchDothis---> branchDothat--->branchDothistoo

some other member of the team advanced the master branch in the repo so after git fetch origin master I had master and origin/master in different commits.

So I was at branch branchDothistoo and I did git rebase origin/master

now I have

master---> origin/master-----> branchDothistoo

so the other two branches are not rebased. (but their commits are there) Is there any way to make them be in the line of commits from origin/master to branchDothistoo?

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150

1 Answers1

1

Yes. Depending on if the other branches have new commits:

  1. If the other branches have new commits of their own, simply check each one out and git rebase origin/master.
  2. If the other branches don't have new commits of their own, while on a branch you wish to duplicate, you can just re-create the others with git branch -f branchDothis, etc. for each branch. Note you could delete them and recreate them, or use the -f flag which mean "force create even if it already exists". The end result is the same.
TTT
  • 22,611
  • 8
  • 63
  • 69
  • for #2 after I do this, what happen with the old `branchDothis`? – KansaiRobot Jun 15 '21 at 05:04
  • @KansaiRobot branches are just pointers to a commit, so you're basically moving the "bookmark" to point to a different commit. If the branch previously pointed to commits that were only reachable from that branch, then those commits will now be dereferenced. Your `reflog` on your machine will keep them around for a default of 90 days in case you want to get them back, and after that they will be garbage collected. – TTT Jun 15 '21 at 05:57