1

I just wanted to ask this to make sure I am doing it correctly, as I don't want to screw up anything.

I created a feature branch (feature1) off of master and have worked on it. However, I really should have created the branch off of dev.

Is this as simple as doing the following?

git checkout feature1
git rebase dev

There are a couple extra things in dev than are not in master.

formicaman
  • 1,317
  • 3
  • 16
  • 32
  • 1
    In theory, yes, but keep in mind that `feature1` has contents that _depend_ on the point where you branched off of `master`, and recreating its progress while branching off of `dev` instead may not be simple. – matt Nov 24 '20 at 17:00
  • The problem with this approach is that if there are revisions in _master_ that are not in _dev_ that _do not belong_ to your feature branch, they would be carried over. – eftshift0 Nov 24 '20 at 17:08
  • @matt Right now, it appears `master` is essentially a subset of `dev`. In other words, `dev` is just `master` with some extra directories. If I were to do a `git rebase` and something went wrong, would that screw up only my feature branch, or the entire `dev` branch as well? – formicaman Dec 02 '20 at 14:12
  • Nothing would "screw up" anything. Nothing is written on tablets of jade. Make safeguards. Then try it and, if you don't like it, undo it. – matt Dec 02 '20 at 14:19

2 Answers2

1

Assuming there are no collisions between master and dev, yes, it would be as simple as that.

If there are considerable conflicts between master and dev, it might be easier to create a new branch out of dev and cherry-pick your changes there.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
0

The way to move only the stuff related to your feature branch would be

git rebase --onto=dev master feature1

That way you are asking git to move the revisions from feature1 skipping all revisions that are included in master, and place them on top of dev.

eftshift0
  • 26,375
  • 3
  • 36
  • 60