有没有一种方法可以将分支重置为master但保留提交历史记录?

我们将TeamCity用于构建。 TeamCity具有VCS构建功能。构建功能使用最新的SHA1来跟踪分支状态,因此它知道要建立的内容。

我们在构建之前使用合并脚本。合并脚本的工作方式为:

 1. Delete the branch for the team (i.e. Team_A)
 2. Branch another Team_A off master
 3. Use the Jira api to grab all branches tagged for Team_A on each ticket
 4. Merge all those branches in
 5. Push

问题:在删除分支并重新创建分支时,我们实际上失去了TeamCity正在跟踪的SHA1。结果是,如果我们想使用VCS构建功能(它本身很有用),则我们无法在任何构建之前运行此合并脚本。

问题:这等同于从大师那里重新分支吗?

 1. Checkout Team_A
 2. rm -r *
 3. git commit ... push # commit and push the removal
 4. git fetch --all # get all updates from origin
 5. git checkout origin/master -- . # checkout all files from master recursively
 6. git commit ... push # commit and push the reset

如果这等效,那么似乎可以解决我的问题,在这里我可以保留SHA1并继续进行合并。

travelwink 回答:有没有一种方法可以将分支重置为master但保留提交历史记录?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2991193.html

大家都在问