0

My branch structure is this way:

---master---feature(commit-x)---task1(commit-y)---task2---

Since task1 is complete, I want to merge the branch to the feature branch and delete it.

What happens to the branch task2 in such a case?

I think the structure will be:

---master---(commit-x)---(commit-y)---task2---
                 |
                 |---feature(merged on task1)

But, then later on completion of task2, I would like to merge it on the feature branch.

How can I accomplish that, please suggest?

Winter
  • 341
  • 1
  • 4
  • 8
  • 1
    Related: [What exactly do we mean by “branch”?](https://stackoverflow.com/q/25068543/1256452) – torek May 06 '20 at 18:03

1 Answers1

0

What happens to the branch task2 in such a case?

Nothing. task2 will remain pointing to the same commit it was pointing before. In fact, task1 will also be unchanged and will point to the same place. Only feature will change (it will have a new commit with the merged contents).

But, then later on completion of task2, I would like to merge it on the feature branch.

Merge task2 into feature the same way you did with task1. Again, both task branches will be unchanged, and feature will now contain the merge of task2 after the merge of task1.

Acorn
  • 24,970
  • 5
  • 40
  • 69
  • The trick is to understand that a branch is just a pointer to a revision. As such, they can be created, moved around, renamed or deleted and they do not affect the revisions they point to – eftshift0 May 06 '20 at 13:15
  • The trick is to understand that the word "branch" means at least 2 different things in git. 1st, a branch is a chain of commits, a part of DAG. And 2nd a branch is a label to a commit. "Removing branch" removes the label but not the chain of commits. – phd May 06 '20 at 15:20
  • @Winter If you unaccept and answer, please provide input why you do so. – Acorn May 15 '20 at 13:55