我们有一个前段时间使用的功能分支(feature
)。来自feature
的更改已集成回开发分支(development
)。但从那以后,development
已被修改,feature
没有,即它有旧代码。我们正在重新审视相同的功能,并希望重用此分支。我们如何确保feature
= development
?
我猜可能有一个重复的问题,但我只是错过了正确的术语。
答案 0 :(得分:5)
您应该从功能分支合并分支git merge development
如果您没有更改功能,它将只是快进到开发。否则,只需解决合并冲突。
答案 1 :(得分:1)
如果您只想丢弃旧的feature
分支:
git checkout master # Make sure we are there
git branch -d feature # Kill old branch dead
git checkout -b feature # New feature branch, starting at current master
但是在这种情况下,我只是将它放在周围(或者可能将其重命名为historic/feature
或类似)并为创建新功能创建一个新分支。
其他选项是在feature
之上重新定位master
(基本上,在那里嫁接它;已经应用的更改应该接管)。
git tag feature save-this-just-in-case # History rewriting might lose it...
git checkout feature
git rebase master
小心,分支feature
不会跟随它!
甚至只需将master
中的更改合并到feature
:
git checkout feature
git merge master
PS:在盲目跟随世界另一端的某人的建议之前,在一些随机网站上匿名发布(半)阅读手册并做一些实验一个临时(副本)存储库。