Tri*_*rip 30 git branching-and-merging
我有两个分支.分期和Beta.暂存中包含代码(包括文件),我根本不需要.如何让Beta完全覆盖Staging,以便这些文件或代码都不会从Staging合并到Beta.
我看到有些人建议这样做:
git checkout staging
git merge -s ours beta
Run Code Online (Sandbox Code Playgroud)
但我不相信预先存在的文件会是"代码冲突",因此不会被删除.我错了吗?如果我是对的,我将如何做到这一点?
Dan*_*rth 29
您可以根据以下内容简单地删除staging
并重新创建它beta
:
git branch -D staging
git checkout beta
git branch staging
Run Code Online (Sandbox Code Playgroud)
Amb*_*ber 23
如果你不关心旧的历史staging
,你可以重新创建它:
git checkout beta
git branch -f staging
Run Code Online (Sandbox Code Playgroud)
如果你关心旧的历史staging
,那么事情变得更有趣:
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.
Run Code Online (Sandbox Code Playgroud)
我建议你重新命名,以防你改变主意.
git branch -m staging staging_oops
git checkout beta
git branch staging
Run Code Online (Sandbox Code Playgroud)
如果你真的不能忍受额外的分支:
git branch -D staging_oops
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
31213 次 |
最近记录: |