Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Kareem Jeiroudi
Kareem Jeiroudi
14,984 Points

Would deleting one branch delete the rest of sub-branches made after this branch?

Let's assume we created a branch named foo_feature, and then, and while I'm on this branch, I created another branch git branch bar_feature. In this case, would deleting the foo_feature branch delete bar_feature too?

2 Answers

Mikkel Rasmussen
Mikkel Rasmussen
31,772 Points

You will still be able to use your bar_feature branch :)

Please take look at this question on stack overflow as this sounds a lot like your question: https://stackoverflow.com/questions/2613903/does-deleting-a-branch-in-git-remove-it-from-the-history

Kareem Jeiroudi
Kareem Jeiroudi
14,984 Points

Thanks a lot for this helpful post. However, my question is not whether or not commits that were merged are attainable:

----O----*----*----/M----*    <-- master <-- HEAD
     \            /
      \--.----.--/--x---y     <-- deleted branch

But you can more or less imagine it this way:

----O----*----*----/M----*    <-- master <-- HEAD
     \            /
      \--.---P.--/--x---y     <-- foo_feature (deleted branch)
               \
                \-----G       <-- bar_feature

In this case, would deleting foo_feature delete the bar_feature branch too, because by the commit P both branches foo_feature and bar_feature shared the same log, if I'm not mistaken.

Mikkel Rasmussen
Mikkel Rasmussen
31,772 Points

It would not delete the bar_feature branch.

From the article: If the branch was merged into another branch before it was deleted then all of the commits will still be reachable from the other branch when the first branch is deleted. They remain exactly as they were.