我有两个分支。分期和Beta。分期中有代码(包括文件),我根本不需要。我怎样才能使Beta完全覆盖Staging,以便这些文件或代码都不会从Staging合并到Beta中。如何覆盖,而不是合并,一个远程分支到另一个分支?
我看到一些人建议这样做:
git checkout staging
git merge -s ours beta
但我不相信预先存在,文件将是一个“代码冲突”,因此不会被删除。我错了吗?如果我是对的,我将如何实现这一目标?
我有两个分支。分期和Beta。分期中有代码(包括文件),我根本不需要。我怎样才能使Beta完全覆盖Staging,以便这些文件或代码都不会从Staging合并到Beta中。如何覆盖,而不是合并,一个远程分支到另一个分支?
我看到一些人建议这样做:
git checkout staging
git merge -s ours beta
但我不相信预先存在,文件将是一个“代码冲突”,因此不会被删除。我错了吗?如果我是对的,我将如何实现这一目标?
我建议如果你改变了主意,你只需将其重命名。
git branch -m staging staging_oops
git checkout beta
git branch staging
如果你实在无法忍受周围具有额外的分支:
git branch -D staging_oops
如果你不在乎关于staging
旧的历史,你可以重新创建:
git checkout beta
git branch -f staging
如果你在意关于staging
旧的历史,那么事情s得到更多的乐趣:
git checkout staging # First, merge beta into staging so we have
git merge -s theirs beta # a merge commit to work with.
git checkout beta # Then, flip back to beta's version of the files
git reset --soft staging # Then we go back to the merge commit SHA, but keep
# the actual files and index as they were in beta
git commit --amend # Finally, update the merge commit to match the
# files and index as they were in beta.
如果分期的历史不会是一个问题,你可以简单地做到这一点。
git checkout staging
git reset --hard beta
只要记住分期的历史将不复存在上面的命令后 分期将有你的测试版分公司的工作。
从'beta'提前'暂停'吗?你们两个分支之间的关系究竟是什么? – Rerito 2013-04-23 14:23:49
他们都有一些未来的数据。但我不想在舞台上做任何事情。 – Trip 2013-04-23 14:50:18