How do I reuse a branch in git?

  • I have a branchA function that started but didn't end.
  • Function B was then requested and executed on the host.
  • Then property B merged with the master.
  • Now I have merged featureA into master because it needs feature B.
  • Now I want to create a new branch called featureA as they are the same feature, but I cannot.

What is the best way to do or manage such things in the future? I don't want to lose my branches ... I want to keep the history of each step. Thank you so much!

featB            /--\
master --------------X--X--------
featA       \----------/   \-- I want to continue here the featB and not 
                               creating featB2, without losing the history.

      

+3


source to share


2 answers


The question was poorly written. This was lacking in my git knowledge. What I had in mind was how to use the same branch name, and here's the answer I'm looking for:

  • Merging feat A with the master
  • Remove feat Fork
  • Create feat Branch again

I didn't know that you can delete a branch or what happens if it was deleted (history loss or so).



From what I understand now, a branch is just a pointer to some commits. Just to know that the commit is not lost somewhere, it was given a name (branch name). When you merge a branch into another, the pointer is still saved to the commit just before the merge commit.

I wish I knew this before ... but thanks for the comments @jthill

+4


source


Simply, I just realized: combine the masters into featA, and I get featA again. Hope this is good practice.



0


source







All Articles