如何在git中重用分支?

时间:2023-01-15 23:43:25
  • I have a branch featureA that got started but not ended.
  • 我有一个分支功能,它已经开始但没有结束。
  • Then featureB was requested and done on the master.
  • 然后在master上请求并完成featureB。
  • Then the featureB merged into master.
  • 然后featureB合并为master。
  • Now I merged the featureA into master because it needed the featureB.
  • 现在我将featureA合并到master中,因为它需要featureB。
  • Now I want to create a new branch called featureA as it's the same feature but I can't.
  • 现在我想创建一个名为featureA的新分支,因为它是相同的功能,但我不能。

What is the best thing to do, or to manage this kind of things in the future? I don't want to lose my branches... I want to keep the history of every step. thanks a lot!

什么是最好的事情,或将来管理这类事情?我不想失去我的分支......我想保留每一步的历史。非常感谢!

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

2 个解决方案

#1


4  

The question was poorly write too. That was lack of my git knowledge. What I meant it was how to use the same branch name and here is the answer I'm looking for:

问题也很糟糕。那是我缺乏的知识。我的意思是如何使用相同的分支名称,这是我正在寻找的答案:

  • Merge feat A into the master
  • 将专长A合并到主人中
  • Delete feat A branch
  • 删除专长分支
  • Create the feat A branch again
  • 再次创建专长A分支

I didn't know that you could delete a branch or what would happen if was deleted (losing history or so).

我不知道你可以删除一个分支,或者如果被删除会发生什么(丢失历史记录等)。

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

从我目前的理解,分支只是指向一些提交的指针。只是要知道提交在某个地方没有丢失,它被赋予了一个名称(分支的名称)。当您将分支合并到另一个分支时,指针仍然在合并提交之前的提交处持续存在。

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

我希望我之前知道...但感谢@jthill的评论

#2


0  

Easy, just figured out: merge the master into the featA and I get featA again.. hope is a good practice

简单,只是想通了:将主人合并到了featA中,我再次获得了featA ..希望是一个很好的做法

#1


4  

The question was poorly write too. That was lack of my git knowledge. What I meant it was how to use the same branch name and here is the answer I'm looking for:

问题也很糟糕。那是我缺乏的知识。我的意思是如何使用相同的分支名称,这是我正在寻找的答案:

  • Merge feat A into the master
  • 将专长A合并到主人中
  • Delete feat A branch
  • 删除专长分支
  • Create the feat A branch again
  • 再次创建专长A分支

I didn't know that you could delete a branch or what would happen if was deleted (losing history or so).

我不知道你可以删除一个分支,或者如果被删除会发生什么(丢失历史记录等)。

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

从我目前的理解,分支只是指向一些提交的指针。只是要知道提交在某个地方没有丢失,它被赋予了一个名称(分支的名称)。当您将分支合并到另一个分支时,指针仍然在合并提交之前的提交处持续存在。

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

我希望我之前知道...但感谢@jthill的评论

#2


0  

Easy, just figured out: merge the master into the featA and I get featA again.. hope is a good practice

简单,只是想通了:将主人合并到了featA中,我再次获得了featA ..希望是一个很好的做法