Lets say I have a main branch, which I take a branch of to work on Feature 1
Main -> Feature 1
I then branch off Feature 1 to create Feature 1 extended
Feature 1 -> Feature 1 extended
Question 1 : After merging Feature 1 to main, can the remote Feature 1 branch be deleted before Feature 1 extended is merged into main? is Feature 1 extended dependent on the remote Feature 1 branch existing?
Question 2 : If I decide I don't want Feature 1, but I do want Feature 1 extended, can I delete the remote Feature 1 branch *before* merging in Feature 1 extended?
I've done some tests, and it appears that it's ok to delete the remote Feature 1 branch in both cases, but I was wondering if there are any gotchas?
CodePudding user response:
Question 1 : After merging Feature 1 to main, can the remote Feature 1 branch be deleted before Feature 1 extended is merged into main? is Feature 1 extended dependent on the remote Feature 1 branch existing?
You can safely delete feature1 branch, feature1extended does not "depend" on feature1 branch.
A branch is a pointer to a commit which itself point to ancestors commit. When you remove a branch, if another branch refers to a commit which has commits of the former in its ancestors, these commits are still reachable.
Note that you might want to rebase feature1extended on main so that feature1extended appears as being branched off main.
Question 2 : If I decide I don't want Feature 1, but I do want Feature 1 extended, can I delete the remote Feature 1 branch before merging in Feature 1 extended?
You can but same explanation as above will still apply and commits of feature1 will appear in feature1extended.
To "forget" commits of feature1, you'll have to use rebase onto
or interactive rebase for example.